Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How to validate 10 Digit US Phone number with Extension using asp.net?

Actually I want enter only following formats

ex: 123-456-7890 / 123-345-5678 Ext 8547965
123 456 7890 / 123 345 5678 Ext 8547965

Please anybody knows Please let me know?
Posted
Updated 29-Sep-14 0:19am
Comments
[no name] 29-Sep-14 2:58am    
u can use regular expression validater in asp.net
24983 29-Sep-14 4:01am    
I used following expression for allowed 7 and 10 digit
"^^(((\(\d{3}\)|\d{3})( |-|\.))|(\(\d{3}\)|\d{3}))?\d{3}( |-|\.)?\d{4}\s*(( |-|\.)?([Ee]xt|[Xx])[.]?( |-|\.)?\d{1,7})?$"

I need to allow 10 digit number and extension and output is
123 456 7890 / 123 345 5678 Ext 8547965

Can u use this type of validation in asp.net
eg:
C#
<asp:RegularExpressionValidator ID="RegExp1" runat="server"
ErrorMessage="Phonenumber must be between 7 to 10 characters"
ControlToValidate="txtPassword"
ValidationExpression="^[0-9]{7,10}$" />
 
Share this answer
 

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