- <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.
- function mobilecheck() {
- var mobile = document.getElementById("phonenumber").value;
- var pattern = /^[1-9]{1}[0-9]{9}$/;
- //var eml = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
- if (pattern.test(mobile)) {
- //alert("Your mobile number : " + mobile);
- return true;
- }
- alert("It is not a valid mobile number. Please input 10 digits only!");
- return false;
- }
Here the validation message for Mobile number pops up, if entered wrong.

Join the conversation! Your thoughts help the community grow.