The CreatorCon Call for Content is officially open! Get started here.

Validation for (xxx) xxx-xxx phone number format

shilpa344
Giga Expert

Need validation for (xxx) xxx-xxx phone number format. Tried regex /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/ but it's accepting other formats as well

1 ACCEPTED SOLUTION

ghsrikanth
Tera Guru

Could you please try this regexp -


/^\([0-9]{3}(\)) [0-9]{3}-[0-9]{4}$/;


View solution in original post

1 REPLY 1

ghsrikanth
Tera Guru

Could you please try this regexp -


/^\([0-9]{3}(\)) [0-9]{3}-[0-9]{4}$/;