javascript (jquery) numeric input: keyCode for '3' and '#' are the same
问题 I need to set up an <input type="text" /> so that it will accept only numeric chars, backspace, delete, enter, tabs and arrows. There's a lot of exemple around there, i started with something similar to this: function isNumericKeyCode (keyCode){ return ( (keyCode >= 48 && keyCode <= 57) //standard keyboard ||(keyCode >= 96 && keyCode <= 105)) //Numpad } $('#myTextBox').keydown(function(e){ var handled = true; var keyCode = e.keyCode; switch(keyCode){ //Enter and arrows case 13: case 37: case