Click here to Skip to main content
14,930,722 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

In my requirement, user can specify the phone number between 9 digits to 14 digits. How can I achieve this in ASP.net with any one of the available validators.
Posted
Comments
Thanks7872 3-Oct-13 2:27am
   
www.google.com
srmohanr 3-Oct-13 2:29am
   
Wow....
Thanks7872 3-Oct-13 2:31am
   
What you mean? If you do a simple google search you will find tons of links related to this.You just need to verify the length of the entered number.

You can use Length validator or regular expression validator In asp.net
   
You can use something as below:

C#
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
<asp:regularexpressionvalidator id="rgvPhoneNumber" controltovalidate="TextBox1" runat="server" validationexpression="^[0-9]{9,14}$" errormessage="Please enter a phone number between 9 and 14 digits">
</asp:regularexpressionvalidator>


-Anurag
   
v3
Comments
srmohanr 3-Oct-13 2:46am
   
Thanks. Its working fine now. Can you please tell me how to add +15 as country code between the phone number..
Anurag Sinha V 3-Oct-13 4:27am
   
http://www.authorcode.com/how-to-use-regular-expression-for-validating-phone-numbers-in-net/

try the above link

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900