DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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, 03:40 PM
  2. sms messaging using Nokia Card Phone.
    By Ram in forum Mobile
    Replies: 1
    Last Post: 10-05-2001, 02:11 AM
  3. Replies: 2
    Last Post: 08-30-2001, 11:32 AM
  4. Formatting Phone number in javascript
    By Gypzees in forum Web
    Replies: 1
    Last Post: 01-04-2001, 05:32 AM
  5. format phone number
    By Brad in forum ASP.NET
    Replies: 1
    Last Post: 07-12-2000, 01:23 PM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links