A
Arpan
Consider the following code which validates a TextBox using
RegularExpression:
<form id="form1" runat="server">
<asp:TextBox id="txt1" runat="server"/>
<asp:RegularExpressionValidator ControlToValidate="txt1"
ValidationExpression="[0-9]{5}-[0-9]{4}|[0-9]{5}" ErrorMessage
="Invalid Input" Display="Dynamic" runat="server"/>
<asp:Button id="btn" Text="SUBMIT" runat="server"/>
</form>
The above RegularExpression Validator control doesn't display the error
message if the text entered in the TextBox is, say, 90210. Why?
Moreover, if the text entered in the TextBox is, say, 54963-87521, then
the error message gets displayed. Why?
I want the text input to have any 5 numbers between 0 & 9 which is
validated by [0-9]{5} followed by a dash which is validated by '-' &
finally followed by either any four numbers between 0 & 9 'or' any five
numbers between 0 & 9 which is validated by [0-9]{4}|[0-9]{5}. So how
is the Validator control passing 90210 but not passing 54963-87521?
Thanks,
Arpan
RegularExpression:
<form id="form1" runat="server">
<asp:TextBox id="txt1" runat="server"/>
<asp:RegularExpressionValidator ControlToValidate="txt1"
ValidationExpression="[0-9]{5}-[0-9]{4}|[0-9]{5}" ErrorMessage
="Invalid Input" Display="Dynamic" runat="server"/>
<asp:Button id="btn" Text="SUBMIT" runat="server"/>
</form>
The above RegularExpression Validator control doesn't display the error
message if the text entered in the TextBox is, say, 90210. Why?
Moreover, if the text entered in the TextBox is, say, 54963-87521, then
the error message gets displayed. Why?
I want the text input to have any 5 numbers between 0 & 9 which is
validated by [0-9]{5} followed by a dash which is validated by '-' &
finally followed by either any four numbers between 0 & 9 'or' any five
numbers between 0 & 9 which is validated by [0-9]{4}|[0-9]{5}. So how
is the Validator control passing 90210 but not passing 54963-87521?
Thanks,
Arpan