www.webdeveloper.com
Results 1 to 3 of 3

Thread: regular expression for phone number

  1. #1
    Join Date
    Feb 2011
    Posts
    90

    regular expression for phone number

    Code:
    var patt1=/[0-9-]/;
    Is the above regular expression will work for the following string?:
    974-45645654-45456445
    5464565464
    4654-4554565

    I am trying to do regular expression for phone number and by that I mean every string that including only number and the "-" char.
    but I don't want the "-" to appear in the beginning.
    Last edited by programAngel; 05-28-2012 at 03:04 AM. Reason: regular expression,

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,671

  3. #3
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,270
    Code:
    /^\d[\d-]+$/.test(onePhoneNumber) // will be true for a valid phone number
    This tests onePhoneNumber beginning with a digit followed by one or more digits or hyphen.
    But with more precision, you must be able to make better, as for example with these post codes...
    Last edited by 007Julien; 05-28-2012 at 08:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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



Recent Articles