var txtPhone = document.getElementById(phoneID); //validating user phone no if (txtPhone.value != "") { var y = txtPhone.value; if (isNaN(y) || y.indexOf(" ") != -1) { alert("Invalid Mobile No."); // return false; } if (y.length > 12 || y.length < 12) { alert("Mobile No. should be entered with country code"); // return false; } if (!(y.charAt(0) == "9" || y.charAt(0) == "8" || y.charAt(0) == "7")) { alert("Mobile No. should start with 9,8 or 7 "); // return false; } }
<input type="tel" name="phone" required=""></input>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)