Regular Expression for Phone Number

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.
 
R

Rad [Visual C# MVP]

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top