jquery - Windows keypad keycodes not working -


i added simple mask text input allows numbers inputted. did using following code:

jquery(function($) {         $("#zip").keydown(function(event) {             // allow backspace , delete             if ( event.keycode == 46 || event.keycode == 8 ) {                 // let happen, don't             }             else {                 // ensure number , stop keypress                 if (event.keycode < 48 || event.keycode > 57 ) {                     event.preventdefault();                  }                }         });     }); 

the issue i'm coming across keypad numbers aren't working on windows (they work find on macs). however, numbers found on top row of keyboard work fine. has come across before?

you not including keycodes numberpad in if statement. should work:

jquery(function($) {     $("#zip").keydown(function(event) {         // allow backspace , delete         if ( event.keycode == 46 || event.keycode == 8 ) {             // let happen, don't         }         else {             // ensure number , stop keypress             if ((event.keycode < 48 || event.keycode > 57 ) && (event.keycode < 96 || event.keycode > 105)) {                 event.preventdefault();              }            }     }); }); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

python 3.5 - Pyqtgraph string in x tick -