I have the following input.
<input type="tel" id="Phone maxlength="10"/>
I'm trying to use Jquery amd regex to validate the number's format.
The jquery / regex is as follows.
$(function () {
var reg = /(([2-9]{1})([0-9]{2})([0-9]{3})([0-9]{4}))$/
var Input = $("input#phone").val();
if ($(z).val() == (reg)) {
alert("Valid")
}
});
This is not working for me, does anyone see why? Or is there a better way to do this?]
/[2-9]\d{9}$/. Unless you are trying to use the groups created by all those parens.