javascript - Validate us number with regular expression -
i'm doing exercise on freecodecamp validate telephone number.
the user may fill out form field way choose long valid number. following valid formats numbers:
555-555-5555, (555)555-5555, (555) 555-5555, 555 555 5555, 5555555555, 1 555 555 5555
i'm using regex test input.i type these expression on regex101
(([1]\s)?(\()*(\d{3})(-|\)|\)\s|\s)*(\d{3})(-|\s)*\d{4})
to test input like:
2 ** (757) 622-7382** return true
-1 (757) 622-7382 return true
10 ** (757) 622-7382** return true
how test leading 2, minus sign , 10.
i suggest have on owasp validation regex repository subject of validation , continuous updates
for phone (at time i'm writing)the suggested regex ^\d?(\d{3})\d?\d?(\d{3})\d?(\d{4})$
Comments
Post a Comment