Environment: IE 4.0 and above
Function Name: "CheckNumeric()"
To use this function, simply call it as an "onkeypress()" event handler in your <INPUT> tag in your HTML code. To see how this is done, view or download the source code below.
This function does not require any input parameters and does not output any return
// Get ASCII value of key that user pressed
var key = window.event.keyCode;
// Was key that was pressed a numeric character (0-9)?
if ( key > 47 && key < 58 )
return; // if so, do nothing
window.event.returnValue = null; // otherwise,
// discard character
DownloadsDownload demo project - .97 Kb
Download source - 1.11 Kb
HistoryDate Posted: January 31, 2002
# # #