Regular Expression for Phone Number

  • Thread starter Thread starter Jake K
  • Start date Start date
J

Jake K

I have a textbox (txtPhoneNumber) that either has to contain 10 numbers (no
other characters) and cannot start with a 1. However... either this textbox
must contain a valid numbr (10 digits and cant start with 1) or it can be
totally blank. What is the best reg expression to use? How is it built?
Are there good utils out there to define expressions?
Thanks a lot.
 
I have a textbox (txtPhoneNumber) that either has to contain 10 numbers (no
other characters) and cannot start with a 1. However... either this textbox
must contain a valid numbr (10 digits and cant start with 1) or it can be
totally blank. What is the best reg expression to use? How is it built?
Are there good utils out there to define expressions?
Thanks a lot.

ASP.NET regex validators seem to let through controls with no text so
blanks won't be a problem. As for the digits try this regex:

^[0,2-9]\d{9}$
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top