I want some help for checking numeric field and string field of a textbox thru Javascript.Ive tried these coding but its not working properly.If you have some other coding plz do fwd it.
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function checkNumeric(objName)
{
var numberfield = objName;
if (chkNumeric(objName) == false)
{
numberfield.select();
numberfield.focus();
return false;
}
else
{
return true;
}
}
function chkNumeric(objName)
{
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789";
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";
for (i = 0; i < checkStr.value.length; i++)
{
ch = checkStr.value.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
alertsay = "Please enter a value greater than or "
alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" + checkStr.name + "\" field."
alert(alertsay);
return (false);
}
</script>
</head>
</html>