regex - validate a 10 digit USA style phone number using a Regular Expression in Javascript -
i want validate 10 digit usa style phone number using regular expression in javascript
it should allow (validate correct) following formats:
xxx-xxx-xxxx 215-121-1247
it should reject invalid:
8059311142 805 931 42ab 105 931 4288
i found regex implement below, can't work.
/^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/
please me on this
you can as:
^\d{3}-\d{3}-\d{4}$
demo: http://regex101.com/r/jv1hp3
to understand regex
doing, check this link
Comments
Post a Comment