javascript - Allow Only Numbers and Letters Does NOT work in Mozilla Firefox -


how can work in mozilla firefox ? works fine in ie , chrome

<script type='text/javascript'>//<![cdata[   function isnumberletter(evtnl)  {              if ((evtnl.keycode >= 48 && evtnl.keycode <= 57) ||                (evtnl.keycode >= 65 && evtnl.keycode <= 90) ||                (evtnl.keycode >= 97 && evtnl.keycode <= 122))                 return true;               return false;         }//]]>    </script> 

if capture keypress event, can charcode:

$(document.body).on('keypress', function(event) {     var isalphanum = string.fromcharcode(event.charcode).match(/[a-za-z0-9]/);     if(isalphanum) {         console.log('letter or number');     } else {         console.log('other key');     } }); 

Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -