Regular Expression for 6 digits number including 0

364 Points
152 Posts

Regular Expression for 6 digits number including 0

Views: 8151
Total Answered: 1
Total Marked As Answer: 1
Posted On: 26-Dec-2014 09:19

Share:   fb twitter linkedin
Rahul Maurya
Rahul M...
1172 Points
211 Posts

If you want a Regular Expression that can accept exactly 6 digits, it would be the following :


An implementation might look something like this :

<!-- Your Textbox --> <asp:TextBox ID="YourTextBox" runat="server"></asp:TextBox> <!-- Your Regular Expression Validator --> <asp:RegularExpressionValidator ID="YourRegularExpressionValidator" runat="server" ControlToValidate="YourTextBox" ErrorMessage="Your TextBox must have exactly 6 digits." ValidationExpression="^\d{6}$"> </asp:RegularExpressionValidator> <!-- This will trigger your validation --> <asp:Button ID="ValidateButton" runat="server" Text="Validate" />
Posted On: 26-Dec-2014 09:22
 Log In to Chat