Check The Validation For Number


 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Sample Code</title>
<script type="text/javascript">
function CheckNumeric(ValueNumeric)
{
var objRegex = /(^-?\d\d*\.\d\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;

//check for numeric characters


if(objRegex.test(ValueNumeric))
{
alert("Your Given Input Is \""+ValueNumeric+"\" Correct.");
}
else
{
alert("Your Given Input Is Not \""+ValueNumeric+"\" Correct.");
}
}
</script>
</head>
<body bgcolor=#00ff00 alink=blue vlink=blue>
<FORM name="windowEvent">
Number : <input type="text" name="txtnumber" />
<input type="button" value="Check Number" name="btnNumber" onClick="CheckNumeric(txtnumber.value)" />
</FORM>
</body>
</html>

Ebook Download
View all
Learn
View all