The javascript code for the data validation is broken if you do not specifiy the UserDateFormat in a "long" format if you do not want to use US date formats.
If you debug then the value.DateFormat passes "DMY" or the like but the switch statement expects "DayMonthYear". If you use a culture you will use the "short" format. If you specify "DayMonthYear" in the UserDateFormat on the MaskedEditExtender then it works as expected.
The offending function is:
function MaskedEditValidatorPartDate(value,mask,MinVl,MaxVl)
Looks like the source is "MaskedEditValidator.pre.js"
And BTW the example site masked edit validator for the date (MaskedEditExtender5) is also wrong in that the Mask value is "99/99/99" when it should be "99/99/9999".
Comments: Yes, this is the method (see full code below, from MaskedEditValidator.pre.js), and in the "switch" statement, "value.DateFormat" is "DMY" for me (which I expect, as I set my web browser Language to "English (United Kingdom)" and I set my web site CurrentCulture and CurrentUICulture to that). ``` function MaskedEditValidatorPartDate(value,mask,MinVl,MaxVl) { var ret = true; var AttibDtFmt = "MDY"; switch (value.DateFormat) { case "DayMonthYear": { AttibDtFmt = "DMY"; break; } case "DayYearMonth": { AttibDtFmt = "DYM"; break; } case "MonthDayYear": { AttibDtFmt = "MDY"; break; } case "MonthYearDay": { AttibDtFmt = "MYD"; break; } case "YearDayMonth": { AttibDtFmt = "YDM"; break; } case "YearMonthDay": { AttibDtFmt = "YMD"; break; } } ``` My MaskedEditExtender is inside a server control, and these are the properties I set: ``` mee = new MaskedEditExtender(); mee.ID = "DateExtender"; mee.TargetControlID = tb.ID; mee.Mask = "99/99/9999"; mee.MessageValidatorTip = true; mee.OnFocusCssClass = "MaskedEditFocus"; mee.OnInvalidCssClass = "MaskedEditError"; mee.MaskType = MaskedEditType.Date; mee.ErrorTooltipEnabled = false; ``` As you can see, I don't set the CultureName. The root of the problem (using the December 15th 2013 Release of ACT source code), start in OnPreRender of MaskedEditExtender.cs: ``` //We Can't rely on the culturename because custom changes may have been made // to the culture settings for the page. Only use the CultureName if it is // specified in the control if (String.IsNullOrEmpty(CultureName)) { CultureName = ""; } ``` This calls the setter of CultureName, which execute these lines: ``` string[] arrDate = ControlCulture.DateTimeFormat.ShortDatePattern.Split(new string[] { ControlCulture.DateTimeFormat.DateSeparator }, StringSplitOptions.None); string ret = arrDate[0].Substring(0, 1).ToUpper(ControlCulture); ret += arrDate[1].Substring(0, 1).ToUpper(ControlCulture); ret += arrDate[2].Substring(0, 1).ToUpper(ControlCulture); CultureDateFormat = ret; ``` My ShortDatePattern is "dd/MM/yyyy", resulting in CultureDateFormat = "DMY". So anyway, the bug is in the js file I would imagine, so my fix is as follow in MaskedEditValidatorPartDate in MaskedEditValidator.pre.js : ``` var AttibDtFmt = "MDY"; switch (value.DateFormat) { case "DayMonthYear": { AttibDtFmt = "DMY"; break; } case "DayYearMonth": { AttibDtFmt = "DYM"; break; } case "MonthDayYear": { AttibDtFmt = "MDY"; break; } case "MonthYearDay": { AttibDtFmt = "MYD"; break; } case "YearDayMonth": { AttibDtFmt = "YDM"; break; } case "YearMonthDay": { AttibDtFmt = "YMD"; break; } case "DMY": case "DYM": case "MDY": case "MYD": case "YDM": case "YMD": { AttibDtFmt = value.DateFormat; break; } } ``` or alternatively, try this: ``` var AttibDtFmt = "MDY"; switch (value.DateFormat) { case "DayMonthYear": case "DMY": { AttibDtFmt = "DMY"; break; } case "DayYearMonth": case "DYM": { AttibDtFmt = "DYM"; break; } case "MonthDayYear": case "MDY": { AttibDtFmt = "MDY"; break; } case "MonthYearDay": case "MYD": { AttibDtFmt = "MYD"; break; } case "YearDayMonth": case "YDM": { AttibDtFmt = "YDM"; break; } case "YearMonthDay": case "YMD": { AttibDtFmt = "YMD"; break; } } ``` The old code was simply doing this, which I'm not reverting to as obviously the new code is fixing something too (whilst breaking something else unfortunately). ``` var AttibDtFmt = value.DateFormat; ``` This bug was introduced here: Committed by Mohinder.j on May 01, 2013. Commit 2d56e79593e8. https://ajaxcontroltoolkit.codeplex.com/SourceControl/changeset/2d56e79593e8491ccc495dc646357d6621b46427 with comment "issue13423 - fixed issue of maskededit(extender/validator) combo problem." Link to issue: https://ajaxcontroltoolkit.codeplex.com/workitem/13423
If you debug then the value.DateFormat passes "DMY" or the like but the switch statement expects "DayMonthYear". If you use a culture you will use the "short" format. If you specify "DayMonthYear" in the UserDateFormat on the MaskedEditExtender then it works as expected.
The offending function is:
function MaskedEditValidatorPartDate(value,mask,MinVl,MaxVl)
Looks like the source is "MaskedEditValidator.pre.js"
And BTW the example site masked edit validator for the date (MaskedEditExtender5) is also wrong in that the Mask value is "99/99/99" when it should be "99/99/9999".
Comments: Yes, this is the method (see full code below, from MaskedEditValidator.pre.js), and in the "switch" statement, "value.DateFormat" is "DMY" for me (which I expect, as I set my web browser Language to "English (United Kingdom)" and I set my web site CurrentCulture and CurrentUICulture to that). ``` function MaskedEditValidatorPartDate(value,mask,MinVl,MaxVl) { var ret = true; var AttibDtFmt = "MDY"; switch (value.DateFormat) { case "DayMonthYear": { AttibDtFmt = "DMY"; break; } case "DayYearMonth": { AttibDtFmt = "DYM"; break; } case "MonthDayYear": { AttibDtFmt = "MDY"; break; } case "MonthYearDay": { AttibDtFmt = "MYD"; break; } case "YearDayMonth": { AttibDtFmt = "YDM"; break; } case "YearMonthDay": { AttibDtFmt = "YMD"; break; } } ``` My MaskedEditExtender is inside a server control, and these are the properties I set: ``` mee = new MaskedEditExtender(); mee.ID = "DateExtender"; mee.TargetControlID = tb.ID; mee.Mask = "99/99/9999"; mee.MessageValidatorTip = true; mee.OnFocusCssClass = "MaskedEditFocus"; mee.OnInvalidCssClass = "MaskedEditError"; mee.MaskType = MaskedEditType.Date; mee.ErrorTooltipEnabled = false; ``` As you can see, I don't set the CultureName. The root of the problem (using the December 15th 2013 Release of ACT source code), start in OnPreRender of MaskedEditExtender.cs: ``` //We Can't rely on the culturename because custom changes may have been made // to the culture settings for the page. Only use the CultureName if it is // specified in the control if (String.IsNullOrEmpty(CultureName)) { CultureName = ""; } ``` This calls the setter of CultureName, which execute these lines: ``` string[] arrDate = ControlCulture.DateTimeFormat.ShortDatePattern.Split(new string[] { ControlCulture.DateTimeFormat.DateSeparator }, StringSplitOptions.None); string ret = arrDate[0].Substring(0, 1).ToUpper(ControlCulture); ret += arrDate[1].Substring(0, 1).ToUpper(ControlCulture); ret += arrDate[2].Substring(0, 1).ToUpper(ControlCulture); CultureDateFormat = ret; ``` My ShortDatePattern is "dd/MM/yyyy", resulting in CultureDateFormat = "DMY". So anyway, the bug is in the js file I would imagine, so my fix is as follow in MaskedEditValidatorPartDate in MaskedEditValidator.pre.js : ``` var AttibDtFmt = "MDY"; switch (value.DateFormat) { case "DayMonthYear": { AttibDtFmt = "DMY"; break; } case "DayYearMonth": { AttibDtFmt = "DYM"; break; } case "MonthDayYear": { AttibDtFmt = "MDY"; break; } case "MonthYearDay": { AttibDtFmt = "MYD"; break; } case "YearDayMonth": { AttibDtFmt = "YDM"; break; } case "YearMonthDay": { AttibDtFmt = "YMD"; break; } case "DMY": case "DYM": case "MDY": case "MYD": case "YDM": case "YMD": { AttibDtFmt = value.DateFormat; break; } } ``` or alternatively, try this: ``` var AttibDtFmt = "MDY"; switch (value.DateFormat) { case "DayMonthYear": case "DMY": { AttibDtFmt = "DMY"; break; } case "DayYearMonth": case "DYM": { AttibDtFmt = "DYM"; break; } case "MonthDayYear": case "MDY": { AttibDtFmt = "MDY"; break; } case "MonthYearDay": case "MYD": { AttibDtFmt = "MYD"; break; } case "YearDayMonth": case "YDM": { AttibDtFmt = "YDM"; break; } case "YearMonthDay": case "YMD": { AttibDtFmt = "YMD"; break; } } ``` The old code was simply doing this, which I'm not reverting to as obviously the new code is fixing something too (whilst breaking something else unfortunately). ``` var AttibDtFmt = value.DateFormat; ``` This bug was introduced here: Committed by Mohinder.j on May 01, 2013. Commit 2d56e79593e8. https://ajaxcontroltoolkit.codeplex.com/SourceControl/changeset/2d56e79593e8491ccc495dc646357d6621b46427 with comment "issue13423 - fixed issue of maskededit(extender/validator) combo problem." Link to issue: https://ajaxcontroltoolkit.codeplex.com/workitem/13423