How to add validation in Mobile Number input field

How to add validation in Mobile Number input field?


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">


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

if(textbox.validity.patternMismatch) {
textbox.setCustomValidity(‘please enter 10 Digit Mobile Number.');
else {
return true;

For Simple 10 Digit Validation:

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

Best WordPress Hosting


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price

Leave a Reply

    Waiting for your comments