Hi,
I want to check whether the string is valid time in 24-hour format or not by using Regular Expression.
My code below.
But this Regular Expression validate 00:00:00 value.
The 00:00:00 value on my case it is not a valid time.
Any suggestion, please.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txHHMMSS" runat="server"
Style="text-align: center; color: brown"
CssClass="pure-u-23-24"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"
ControlToValidate="txHHMMSS"
SetFocusOnError="true"
ErrorMessage="Required" Display="None"
ValidationGroup="Validation2"
CssClass="validation-summary-errors-one"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator13" runat="server" Display="None"
ErrorMessage="Required"
ControlToValidate="txHHMMSS"
ValidationExpression="^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$" Text="*"
ValidationGroup="Validation2"></asp:RegularExpressionValidator>
<br />
<br />
<asp:ImageButton ID="btn" runat="server"
ValidationGroup="Validation2"
OnClick="btn_Click"
ImageUrl="/Images/confirm.gif"
OnClientClick="if (!confirm('Confirm?')) return false;"
CausesValidation="true" />
</div>
<asp:ValidationSummary ID="ValidationSummary1"
ValidationGroup="Validation2" runat="server"
ShowSummary="false"
ShowMessageBox="true"
CssClass="validation-summary-errors" />
</form>
</body>
</html>