2
Vote

MaskedEditExtender fails when MaskType="DateTime" after focus out

description

AjaxControlToolkit 4.1.51116.0
MaskedEditExtender does not allow the time to be set. When the textbox loses focus the hour and minute are set to the two digit month and two digit day used in the date portion.

<asp:TextBox ID="txtDateTime1" runat="server"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender ID="mskDateTime1" runat="server"
Mask="99/99/9999 99:99" MaskType="DateTime" TargetControlID="txtDateTime1"  
UserTimeFormat="None" AcceptAMPM="false"> 
</ajaxToolkit:MaskedEditExtender>

comments

Orlangur wrote Jul 31, 2012 at 11:54 AM

The bug happens in cultures using DMY date format

Orlangur wrote Jul 31, 2012 at 12:00 PM

In 3.0.20820 the bug also happened but only when setting culture override to CultureName property (to "ru-RU", for example). In 4.1.60623 it happens even if CultureName is not set.

Orlangur wrote Jul 31, 2012 at 12:26 PM

The error is in AutoFormatTime function:

...
    if (this._MaskType == Sys.Extended.UI.MaskedEditType.DateTime)
    {
        var arr = this._SplitDateTime(ValueText);
        var time_arr = arr[1].split(" ");
        if (time_arr.length == 2) 
        {
            ValueText = time_arr[0] + " " + time_arr[1];
        }
        else 
        {
            ValueText = arr[0];
        }
...

last line should be:

ValueText = time_arr[0]