Mobile Number Validation In SharePoint

Set the onfocusout event for this button as shown below.

  1. <div>Mobile No: <input type="number" id="phonenumber" onfocusout="mobilecheck();"></div>  

Create a function representing a link to that button and it gets executed when triggered. 

  1. function mobilecheck() {  
  2.     var mobile = document.getElementById("phonenumber").value;  
  3.     var pattern = /^[1-9]{1}[0-9]{9}$/;  
  4.     //var eml = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
  5.     if (pattern.test(mobile)) {  
  6.         //alert("Your mobile number : " + mobile);  
  7.         return true;  
  8.     }  
  9.     alert("It is not a valid mobile number. Please input 10 digits only!");  
  10.     return false;  
  11. }   
Go to the site page and start filling in the details.
Here the validation message for Mobile number pops up, if entered wrong.
 
SharePoint 

Sharepoint