To validate Phone number using regular expression in java script.
In india phone is 10 digit and starting digits are 6,7,8 and 9.
Javascript and HTML code:
function validate()
{
var text = document.getElementById("pno").value;
var regx = /^[6-9]\d{9}$/ ;
if(regx.test(text))
alert("valid");
else
alert("invalid");
}
_x000D_
<html>
<head>
<title>JS compiler - knox97</title>
</head>
<body>
<input id="pno" placeholder="phonenumber" type="tel" maxlength="10" >
</br></br>
<button onclick="validate()" type="button">submit</button>
</body>
</html>
_x000D_