javascript - Tab keypress don't work in Firefox -


i'm using function, , i'm trying figure out why tab button not work in firefox. regex works in others browsers.

$('#email').on('keypress', function(event) {             var regex = new regexp("^[a-za-z0-9_@.\b\t]+$");             var key = string.fromcharcode(!event.charcode ? event.which : event.charcode);             if (!regex.test(key)) {                 event.preventdefault();                 return false;             }         }); 

i'dont understand why works, problem solved adding

if ([0, 8].indexof(charcode) !== -1) return;

$('#email').on('keypress', function(event) {             var regex = new regexp("^[a-za-z0-9_@.\b]+$");             var charcode = !event.charcode ? event.which : event.charcode;             console.log([0, 8].indexof(charcode));             if ([0, 8].indexof(charcode) !== -1) return;             var key = string.fromcharcode(charcode);             if (!regex.test(key)) {                 event.preventdefault();                 return false;             }         }); 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -