
simple javascript validation for register number

Here is a html code that accepts number from the user and check whether the entered value is valid.
<html>
<head>
<title>Mobile number validation using regex</title>
<script type="text/javascript">
function validate() {
var mobile = document.getElementById("mobile").value;
var pattern = /^\d{10}$/;
if (pattern.test(mobile)) {
alert("Your mobile number : "+mobile);
return true;
}
alert("It is not valid mobile number.input 10 digits number!");
return false;
}
</script>
</head>
<body>
<h2>Validating mobile number..</h2>
Enter Mobile No. :
<input type="text" name="mobile" id="mobile" />
<input type="submit" value="Check" onclick="validate();" />
</body>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.