Enter Numbers Only
The box above will only allow numbers to be entered. It will reject all other characters.
Here is the javascript function:
<script>
<!--
function numbersOnly(field, event) {
var key, keychar;
if (window.event)
key=window.event.keyCode;
else if (event)
key=event.which;
else
return true;
keychar=String.fromCharCode(key);
if ((key==null) || (key==0) || (key==8) ||
(key==9) || (key==13) || (key==27) )
return true;
else if ((("0123456789").indexOf(keychar) > -1))
return true;
else return false;
}
//-->
</script>
Call the function from within an input object.
<input type="text" name="serialnumber" size="10" maxlength="10"
onkeypress="return numbersOnly(this, event)">
RETURN