10 digit mobile number validation in javascript

Today, We want to share with you mobile number validation in javascript.In this post we will show you simple phone number validation in javascript, hear for 10 digit mobile number validation in javascript we will give you demo and example for implement.In this post, we will learn about jquery validate phone number with an example.

How to validate mobile number using Javscript?

index.html

<!DOCTYPE html>
<html>
<head>
<title>Validate mobile number Javascript - www.pakainfo.com</title>
</head>
<body>
<input id="userInputData" type="text" onkeypress="return isNumber(event)" />
<input type="button" value="Update" onclick="ValidateNo();">
<script>
function isNumber(evt) {
  evt = (evt) ? evt : window.event;
  var numbertype = (evt.which) ? evt.which : evt.keyCode;
  if (numbertype > 31 && (numbertype < 48 || numbertype > 57)) {
    alert("Please enter only Numbers. Not any String or Special Char");
    return false;
  }

  return true;
}

function ValidateNo() {
  var moNumber = document.getElementById('userInputData');

  if (moNumber.value == "" || moNumber.value == null) {
    alert("Please enter your Cell No.");
    return false;
  }
  if (moNumber.value.length < 10 || moNumber.value.length > 10) {
    alert("Sorry, Cell No. is not valid, Please Enter Your Working 10 Digit Cell No.");
    return false;
  }

  alert("Good Luck Success ");
  return true;
}
</script>
</body>
</html>

I hope you get an idea about phone number validation regex javascript.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.