Regular expression for validate Mobile number using RegularExpressionValidator in ASP.Net

Last Reply 2 months ago By Mahesh1986

Posted 2 months ago

can anybody help me regarding regular expreesion for mobile number .that should allow only numbers and should contain 10digits.


googled  somany contect but not find exactly.


some are giving error when i entered bellow 10 digits.but if i enter 12 digits error is not giving.

Posted 2 months ago

Hi Mahesh1986,

Refer the below sample.


<asp:TextBox runat="server" ID="txtMobileNumber" />
<br />
<asp:RequiredFieldValidator ID="rfvMobNo" runat="server" ErrorMessage="Required"
    Display="Dynamic" ValidationGroup="Validate" ForeColor="Red" ControlToValidate="txtMobileNumber"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revMobNo" runat="server" ErrorMessage="Invalid Mobile Number."
    ValidationExpression="^([0-9]{10})$" ControlToValidate="txtMobileNumber" ValidationGroup="Validate"
    ForeColor="Red" Display="Dynamic"></asp:RegularExpressionValidator>
<br />
<asp:Button Text="Submit" runat="server" OnClick="Submit" ValidationGroup="Validate" />


I agree, here is the link: