1

Closed

MaskedEditBehavior. ConvFmtTime : function(input,loadFirst) fails if this._CultureAMPMPlaceholder == ""

description

If the this._CultureAMPMPlaceholder == "", ConvFmtTime fails when creating a regular expression: Microsoft JScript runtime error: Expected ')' in regular expression

CODE:

, ConvFmtTime : function(input,loadFirst)
{

//.......

var LDLcAM = "";
var LDLcPM = "";
if (this._CultureAMPMPlaceholder != "") //// FALSE so LDLcAM and LDLcPM remains empty
{
   LDLcAM = this._CultureAMPMPlaceholder.split(this._AMPMPlaceholderSeparator)[0];
   LDLcPM = this._CultureAMPMPlaceholder.split(this._AMPMPlaceholderSeparator)[1];
}
// convert current Culture to user culture format (24H)
if (this.get_UserTimeFormat() == AjaxControlToolkit.MaskedEditUserTimeFormat.TwentyFourHour) //// TRUE
{
  input = input.replace(new RegExp("(\\" + LDLcAM + ")", "g"),""); //// RegExp string goes "(\\)" resp. (\), which leads to error
  if (input.indexOf(LDLcPM) != -1)
  {
     AddH = 12;
  }
  input = input.replace(new RegExp("(\\" + LDLcPM + ")", "g"),"");
}

//.....
}
Closed May 3, 2013 at 7:11 AM by Superexpert
Issues is closed as we are not able to reproduce. Please reopen with sample code if someone still getting problem with this issue.

comments

HubertoKusters wrote Sep 29, 2010 at 2:36 PM

I had the same problem. Turns out that my culture is nl-NL (default), and with this I have no AMPM placeholder.
So I changed the property CultureName to en-GB, which solved the problem for me.

bocca wrote Oct 19, 2011 at 10:31 PM

A solution without Toolkit recompilation. Tested on 4.1.50401.0 version:

try { p = Sys.Extended.UI.MaskedEditBehavior.prototype; } catch (e) { p = null; }
if (p != null) {
function funcbody(f) {
    var s = f.toString();
    return s.substring(s.indexOf('{'));
}
p.ConvFmtTime = new Function("m", "z",
    'var c=-1,e=" ",a="",b=false,f=10,d=true,k="g",i=")",j="(\\\\",h="0";' +
    funcbody(p.ConvFmtTime)
    .replaceAll('TwentyFourHour', 'TwentyFourHour&&v!=a'));
}