0
votes

I have a TextBox and AjaxControlToolkit MaskedEditExtender for users to enter a time. The control is bound to a timespan property in code (and time(7) column in SQL Server). The requirement is to ensure that all times are between 1800h and 0000h (it's for bat recording). Can anyone suggest how to use the MaskedEditValidator to ensure the time entered is in this range?

My code so far:

<asp:TextBox ID="txtEmergenceTime" runat="server"  CssClass="formInput"
    Text='<%# Eval("EmergenceTime", "{0:hh\:mm}") %>' />
<asp:MaskedEditExtender ID="meeEmergenceTime" runat="server"
    TargetControlID="txtEmergenceTime" Mask="99:99" MaskType="Time"
    AutoComplete="false" AutoCompleteValue="0"/>
<asp:MaskedEditValidator ID="valEmergenceTime" runat="server"
    ErrorMessage="Emergence time must be between 18:00 and 00:00"
    CssClass="error" ControlToValidate="txtEmergenceTime"
    ValidationGroup="roostCount">*</asp:MaskedEditValidator>
1

1 Answers

1
votes

You may set interval from 18:00 to 23:59 and utilize MaskedEditValidato's MinimumValue and MaximumValue properties. Or you can define ClientValidationFunction property for validator extender and use custom validation