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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write regular expression for this case?

Status
Not open for further replies.

zbx888

Programmer
Joined
May 16, 2005
Messages
1
Location
US
I want to use Javascript to validate user input for last name and first name by regular expression and just allow usa alphebetical letters plus space, apostroph and hyphen such as O'Neill and Lacova-D'elia.

How to write regular expression to validate user's input? Thanks a lot!
 
I wouldn't use \s. I'd use a literal space. \s includes ANY WHITESPACE, including tab, linefeed and carriage return. Although in a single-line textbox you shouldn't encounter the latter two, the former is a possibility. It pays to be precise about what you want.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top