How to add validation in Mobile Number input field

How to add validation in Mobile Number input field?

0 5138

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:

SSL for business, from $12.88


Leave a Reply


Comments
    Waiting for your comments

Coding Tag WhatsApp Chat
Coding Tag WhatsApp Chat