How to add validation in Mobile Number input field
×


How to add validation in Mobile Number input field?

4371

How to validate the input field of Mobile Number?

For professional, it's important to user don't enter wrong values, for that we should have to validate all the fields like mobile number field, email id field.

Please check how can u easily validate the mobile number field..

<form action="javascript:void(0);">

<input id="phonenumber" maxlength="10" pattern="^\d{4}\d{3}\d{3}$" required="" oninvalid="InvalidMsg(this);"
oninput="InvalidMessage(this);" type="text" placeholder="Mobile Number" />

<input type="submit">

</form>

<script language="javascript">
function InvalidMessage(textbox) {

if(textbox.validity.patternMismatch) {
textbox.setCustomValidity(‘please enter 10 Digit Mobile Number.');
}
else {
textbox.setCustomValidity(");
}
return true;
}
</script>

For Simple 10 Digit Validation:

<input maxlength="10" type="text">



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments