by Hiroshi on June 15th, 2008

Following script will check that whether user has entered the number or digit in field. e.g. In Phone Number Text Field.

Head Section Code

Use this script in head section of webpage or call an external javascript file with this code.

<script language="javascript">
function CheckData()
{
with(document.send)
{
if (mobile.value == "")
{
alert("Please enter a value for the \"numbers\" field.");
mobile.focus();
mobile.value="";
return (false);
}
// only allow numbers to be entered
 
var checkOK = "0123456789";
var checkStr = mobile.value;
var allValid = true;
var allNum = "";
for (i = 0; i < checkStr.length; i++)
{
ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
if (ch != ",")
allNum += ch;
}
if (!allValid)
{
alert("Please enter only digit characters in the \"numbers\" field.");
mobile.focus();
mobile.value="";
return (false);
}
}
return true;
}
</script>

Form Code

<form name=send action="msn.com" method="post" id="mobile" onSubmit="return CheckData()">
<input name="mobile" type="text" id="mobile" />
<input type="submit" name="Submit" value="Submit" />
</form>

Download Number Validation or Authentication Script

  • Share/Bookmark

,

Leave a Review

Incoming Searches

php number validation, number validation in php, mobile number validation in php, mobile validation in php, no validation in php, number validation php, mobile number validation php, php mobile number validation, php validate mobile number, php telephone only numbers, php script for contact no validation, php validate a mobile phone number, php phone number validation, php number verification, number field length validation php, php validating numbers, validation script in php for mobile number, validation in javascript for mobile number, validation for contact number in php, validate only numbers in php, validate number inPHP, validate form php phone script, validate field value with random values, validate cell number php, text field number only input in php, php validation for number only, validation script in php for number, php mysql validate number input, php code to validate mobile number, contact form php script for mobile, generate random mobile numbers free javascript, how to validate cell no in php, how to validate mobile no in PHP, how to validate mobile no using php, how to validate mobile number with php, input a number and check it magic number or not in php, javascript validating Mobile number, mobile number validation in javascript, mobile number validation in javascript php, mobile number validation script in forms, mobile number verification php script, no image validation from mobile, number validation using php, only number validation in php, phone and mobile number validation in php, PHONE NUMBER IN PHP CONCATENATION, code in php for mobile number validation