Skip to content

Instantly share code, notes, and snippets.

@maxparm
Created March 26, 2012 23:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maxparm/2210761 to your computer and use it in GitHub Desktop.
Save maxparm/2210761 to your computer and use it in GitHub Desktop.
JS - jQuery Allow only numeric characters in HTML input
$(function(){
$('input[name="number"]').bind('keypress', function(e){
var keyCode = (e.which)?e.which:event.keyCode
return !(keyCode>31 && (keyCode<48 || keyCode>57));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment