Created
December 14, 2017 09:50
-
-
Save zmiftah/c57184eecd74d9c7cfb6d02ec75a868d to your computer and use it in GitHub Desktop.
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
let input = $('#txt_number') | |
function validateNumberKey(e) { //keydown | |
let newVal = this.value + e.key | |
return e.keyCode == 36 || // e.key=Home | |
e.keyCode == 8 || // e.key=Backspace | |
e.keyCode == 37 || // e.key=ArrowLeft | |
e.keyCode == 39 || // e.key=ArrowRight | |
$.isNumeric(newVal) | |
} | |
input.on('keydown', validateNumberKey) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment