Skip to content

Instantly share code, notes, and snippets.

@crstamps2
Created September 9, 2013 15:16
Show Gist options
  • Save crstamps2/6497040 to your computer and use it in GitHub Desktop.
Save crstamps2/6497040 to your computer and use it in GitHub Desktop.
For checking a field for only digits and space using JQuery
$('#id').keypress(function(e){
var key_codes = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 8, 32];
if (($.inArray(e.which, key_codes) >= 0) !== true) {
e.preventDefault();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment