Search code examples
c#.netvalidationmaskededitextender

ajaxToolkit:MaskedEditExtender - is there a way to write a custom MaskType or can I use "Time" after all?


I'm trying to use ajaxToolkit:MaskedEditExtender for a time interval input. Now I want to be able to allow for hours:minutes, but the way I do it, it only allows for 00:00 to 23:59. I however need it to also allow 999:59, i.e. I don't want a time of the day but to set an interval.

               <ajaxToolkit:MaskedEditExtender 
                    runat="server" 
                    ID="StartTimeMaskedEdit" 
                    MaskType="Time" 
                    Mask="999:99" 
                    TargetControlID="TimeOutTextBox" 
                    ClearMaskOnLostFocus="true" 
                    AutoComplete="true" 
                    AutoCompleteValue="000:00" />          

               <ajaxToolkit:MaskedEditValidator 
                    runat="server" ID="StartTimeMaskedEditValidator" 
                    ControlExtender="StartTimeMaskedEdit" 
                    ControlToValidate="TimeOutTextBox" 
                    IsValidEmpty="false" 
                    InvalidValueMessage="*Invalid Time" 
                    InvalidValueBlurredMessage="*Invalid Time" />

When I use MaskType="number", the problem is such that the colon disappears once the input field loses focus (probably because a colon is not a valid part of a number). It reappears on focus, but that's not good enough.

Is there a way to write a custom MaskType or to allow for the above within the MaskType="Time" or "number" constaints ?


Solution

  • I removed the validation part and do so in the codebehind now