<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Validate Field With Only Digits Allowed</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="author" content="Roderick Divilbiss">
<meta name="copyright" content="© 2005-2010 Roderick Divilbiss">
<script type="text/javascript">
<!--
function checkDigitsOnly(fld) {
var phone = fld.value;
var RegExPattern = /^[0-9]+$/;
if ((phone.match(RegExPattern)) && (phone!='')) {
return true;
} else {
alert("Phone number contains invalid characters!\n Only Numbers are allowed.\n\t 5555555555"); //if any invalid chars
fld.focus();
return false;
}
}
//-->
</script>
</head>
<body>
<input type="text" name="intPhone" onblur="checkDigitsOnly(this);" size="25" />
</body>
</html>
Date Validation Using JavaScript .
Cross-Browser Clipboard Copy .
Loading Images With Remote Scripting .
Why JavaScript In Hyperlinks Is Bad .
Change The Submit Button To Show Waiting For AJAX Response .
European Date Validation Using JavaScript .
Database Results To Client Side Array .
Reading Files With JavaScript .
AJAX For Plain Text And HTML .