Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expressions

Status
Not open for further replies.

megabyte214

Programmer
Nov 7, 2001
40
US
I am trying to use a regular expression to validate phone number as format (585)555-1212.

I tried it 2 ways:

["regexp=^\([0-9]{3}\)[0-9]{3}\-[0-9]{4}$", "Please give your Phone as format (585)555-1212"]

^\(\d{3}\)\d{3}\-\d{4}$
 
your second regex works. try this in your browser's location box:

javascript:str='(585)555-1212'; if(/^\(\d{3}\)\d{3}\-\d{4}$/.test(str))alert(1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top