mobile validation using html code example
Example 1: how to validate mobile number in html form
<div>
<label for="phone">Enter your phone number:</label>
<input type="tel" id="phone" name="phone" pattern="+94[7-9]{2}-[0-9]{3}-[0-9]{4}" value="+94">
</div>
Example 2: javascript phone number input
function phonenumber(inputtxt)
{
var phoneno = /^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/;
if((inputtxt.value.match(phoneno))
{
return true;
}
else
{
alert("message");
return false;
}
}