Reputation: 10777
I am trying to put a validator in my page that checks the value of a textbox and prints the error message if the value of the textbox is not a number of length 3. Here it is:
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="tCourse" ErrorMessage="Enter a number of length 3!"
ForeColor="Red" ValidationExpression="^[0-9]]{3}$"></asp:RegularExpressionValidator>
The problem is, even though i enter a number like "432" into the box, it still gives the error message. What is wrong here can anyone see?
Thanks
Upvotes: 2
Views: 65
Reputation: 11920
You have ^[0-9]]{3}$
there is a double closing ]
, try ^[0-9]{3}$
Upvotes: 1
Reputation: 27926
Your RegEx has an extra "]" in it:
^[0-9]]{3}$
Should be:
^[0-9]{3}$
If you're curious, your current regex should match "4]]]" as a valid entry
Upvotes: 2