JavaScript Form Validation
HTML form validation can be done by JavaScript.
Numeric Field validation
Validate Mobile Number
Check field should not null
Validate fiels should contained only Numeric Value
Field should Not take more than 10 digits
Example
<script>
function validateForm()
{
if(isNaN(document.myform.num.value)||document.myform.num.value==""||document.myform.num.value.length>10)
{
alert("Please Enter 10 Numbers only");
document.myform.num.focus();
return false;
}
else{
var number=document.getElementById('num').value;
document.write("Your Mobile Number is: " +number+"
");
}
}
</script>
<form name="myform" onsubmit="return validateForm()" method="post">
Enter your Mobile Number:<input type="text" name="num" id="num" />
<input type="submit" value="Submit>
</form>
Run Example>>