Regular expression to match up to ten digits

Possible duplicate:
How to create a regular expression for receiving no more than 10 digits?

I want a regular expression that will allow up to 10 digits in a user element that has a text box. (ASP.net 3.5).

+4
source share
2 answers

^[0-9]{1,10}$ or ^\d{0,10}$

+5
source

Add a regular expression checker to the text box:

 <asp:TextBox ID="tb" runat="server" MaxLength="10" /> <asp:RegularExpressionValidator ID="rvDigits" runat="server" ControlToValidate="tb" Text="*" Display="Dynamic" ValidationExpression="^\d{0,10}$" /> 

A better approach would be to use jQuery and the jquery.numeric plugin!

+1
source

Source: https://habr.com/ru/post/1286657/


All Articles