I want to get the input from the user as 888-999-6666..i.e. 3 numbers then a '-' then 3 numbers then again '-' and finally 4 numbers. I am using the following regular expression in my JavaScript.
var num1=/^[0-9]{3}+-[0-9]{3}+-[0-9]{3}$/;
if(!(form.num.value.match(num1)))
{
alert("Number cannot be left empty");
return false;
}
But its not working.
If I use var num1=/^[0-9]+-[0-9]+-[0-9]$/; then it wants at least two '-' but no restriction on the numbers.
How can i get the RE as my requirement? And why is the above code not working?
var num1=/^[0-9]{3}+-[0-9]{3}+-[0-9]{3}$/;typo near last symbol class? Did you mean{4}?+after{}acts like a possessive quantifier which was supported by php but js won't