Thursday, 15 January 2015

javascript - What's the best regex to validate names? -



javascript - What's the best regex to validate names? -

this question has reply here:

regex names 21 answers regular look first , lastly name 11 answers

i'm creating web store , need validate inputs javascripts user doesn't have submit form given php errors (although i'm validating form php).

what came next regex:

/^[a-za-z]+$/

but above regex allow alpha characters whereas want allow characters such ' , - since names may contain these 2 characters. question is, how create regex allow alpha characaters , 2 characters above.

besides have 1 more question came in mind, characters such ă pass above validation ?

by adding them character grouping so

/^[a-za-z'-]+$/

javascript regex forms validation

No comments:

Post a Comment