Created
July 3, 2013 17:48
-
-
Save caseymhunt/5920945 to your computer and use it in GitHub Desktop.
JS & jQuery script that only allows numbers in a specified text field based on vanilla JS key mappings(code): http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
This file contains hidden or 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
| $('#elementID').keydown(function (event) { | |
| if (event.keyCode > 57) { | |
| if (event.keyCode < 96 || event.keyCode > 105) { | |
| event.preventDefault(); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment