Created
November 12, 2018 16:33
-
-
Save Lysindr/602c5fd336a16d975152477030659d7b to your computer and use it in GitHub Desktop.
Validate Input on numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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