Regular Expression for a phone number.. here is my code...

Discussion in 'JavaScript' started by locals, Dec 6, 2009.

  1. #1
    Hi I have this code :

    ^[\(]?(\d{0,3})[\)]?[\s]?[\-]?(\d{3})[\s]?[\-]?(\d{4})[\s]?[x]?(\d*)$

    LOL some how it is supposed to be used as my " regular expression " for an input area on a contact form... problem is I DONT KNOW WHAT IN THE WORLD THAT CODE "SAYS"

    I pasted it in the area where it is supposed to go, but when i did a sample test and even left out a digit it still accepted the entry.

    I would like it to even add a hypen after the first and second set of 3rd digits... but i dont know where to begin :eek:

    Thanks in advance !
     
    locals, Dec 6, 2009 IP