[Solved] Regex for Phone Number validation in JavaScript [closed]


You have a ? quantifier for ( and ) in your regex, which matches your parentheses for zero or one times. Simply removing it will do the trick.

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

Have a test for it here

1

solved Regex for Phone Number validation in JavaScript [closed]