How
to validate mobile number must be
numeric and 10 digits.
<script type="text/javascript">
function
ValidateMobNumber(txtMobId) {
var fld =
document.getElementById(txtMobId);
if (fld.value
== "") {
alert("You didn't enter a phone number.");
fld.value = "";
fld.focus();
return false;
}
else if (isNaN(fld.value)) {
alert("The phone number contains illegal characters.");
fld.value = "";
fld.focus();
return false;
}
else if (!(fld.value.length == 10)) {
alert("The phone number is the wrong length. \nPlease
enter 10 digit mobile no.");
fld.value = "";
fld.focus();
return false;
}
}
</script>
<input type="text" id="txtMB" onblur="return ValidateMobNumber('txtMB')" />
<!--Or Call on Button-->
<input type="submit" id="btnVal" value="Save" onclick="return ValidateMobNumber('txtMB') />
No comments:
Post a Comment