Skip to content

Instantly share code, notes, and snippets.

@bandicsongor
Created August 8, 2013 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bandicsongor/6184315 to your computer and use it in GitHub Desktop.
Save bandicsongor/6184315 to your computer and use it in GitHub Desktop.
cand be used on textboxes to verify if the pressed key is a number, can be used as: onkeypress = 'return isNumber(event)'
function isNumber(evt)
{
evt = (evt) ? evt : window.event;
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment