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}$
 
Back
Top