How would I write a validation expression for a Phone number


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How would I write a validation expression for a Phone number

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    PA
    Posts
    259

    How would I write a validation expression for a Phone number

    I'm trying to figure out how to write a validation expression that would allow these formats : (xxx)xxx-xxxx , 123456789


    anyone know of any validation expressions that is somewhat like that or exactly like that or better ?

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Take a look at http://regexlib.com/
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Oct 2012
    Posts
    1

    phone number expression

    well, for your first example (xxx) xxx-xxxx , the expression would be
    ^\([2-9]\d{2}\) \d{3}[- .]?\d{4}\D*(\d*)$

    and for your second example, xxxxxxxxxx , the expression would be short and simple....
    ^\d{10}$


    good luck!

Similar Threads

  1. Replies: 3
    Last Post: 06-19-2003, 04:40 PM
  2. sms messaging using Nokia Card Phone.
    By Ram in forum Mobile
    Replies: 1
    Last Post: 10-05-2001, 03:11 AM
  3. Replies: 2
    Last Post: 08-30-2001, 12:32 PM
  4. Formatting Phone number in javascript
    By Gypzees in forum Web
    Replies: 1
    Last Post: 01-04-2001, 06:32 AM
  5. format phone number
    By Brad in forum ASP.NET
    Replies: 1
    Last Post: 07-12-2000, 02:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center