Tuesday, July 29, 2008

Javascript to accept only numeric values

Here is the javascript code to accept only numeric values in textboxes. This has to binded to
"onkeypress" event.


function onlyInteger(evt)
{
evt = window.event;
var charCode = evt.keyCode;
if (charCode > 31 && (charCode <> 57)) {
status = "This field accepts numbers only.";
return false;
}
status = "";
return true;
}
-::-

No comments: