Skip to content

Instantly share code, notes, and snippets.

@Lysindr
Created November 12, 2018 16:33
Show Gist options
  • Save Lysindr/602c5fd336a16d975152477030659d7b to your computer and use it in GitHub Desktop.
Save Lysindr/602c5fd336a16d975152477030659d7b to your computer and use it in GitHub Desktop.
Validate Input on numbers
validateInputOnNumberKeyPress($('input[type="number"]'));
function validateInputOnNumberKeyPress(input) {
input.keypress(function (e) {
if (e.which != 8 && e.which != 0 && e.which != 13 && (e.which < 48 || e.which > 57)) {
return false;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment