Sreenish

Sreenish

  • NA
  • 249
  • 31.7k

Anyone Know?

Aug 10 2015 1:35 AM
did any one know how to validate time in textbox using two checkboxes .i mean 12hr in one checkbox and 24hr in another checkbox.if user clicks 12hr checkbox it should validate only 12 hr same for 24 hr..how to do this any idea help me.am posting what i have done.
 
Code:
 
 
<div>
<asp:TextBox ID="txtTime" runat="server">
</asp:TextBox>
<asp:CheckBox ID="Chk1" runat="server" Text="12hr" onclick="fnCheckOne(this)"
/>
<asp:CheckBox ID="Chk2" runat="server" Text="24hr" onclick="fnCheckOne(this)" />
<asp:RegularExpressionValidator ID="regex1" runat="server" ErrorMessage="InvalidTime"
ControlToValidate="txtTime" ValidationExpression="^(1[0-2]|0[1-9]):[0-5][0-9]\040(AM|am|PM|pm)$">
</asp:RegularExpressionValidator>
<asp:RegularExpressionValidator ID="regex2" runat="server" ErrorMessage="InvalidTime"
ControlToValidate="txtTime" ValidationExpression="^([01]?[0-9]|2[0-3]):[0-5][0-9]$">
</asp:RegularExpressionValidator>
</div>
 

Answers (6)