0
Good morning, I am developing a form where I have a field "username", in this field I use this RegExp("^[0-9a-zA-Z \b]+$")
, works perfectly, however at the time I use the TAB key to advance to the next field it does not work! I tried to use \t
, but without success.
Some dirt?
Follows code:
$('#usuario').bind('keypress', function (event){
var regex = new RegExp("^[0-9a-zA-Z \b]+$");
var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
if (!regex.test(key)){
event.preventDefault();
return false;
}
});
Could you demonstrate how you are using this regex? by
input pattern
?mark
, or even a function? this applied in areplace
?– Guilherme Lautert
Could you post your code? Or a part of it?
– Rubico
I posted the code
– Paul Polidoro
Which browser are you using? What type of input is the user element? I tested your code here and it worked perfectly.
– Rubico
The browser is Firefox v44, well placed, I tested on Chrome and it really worked, the problem would be in Firefox?
– Paul Polidoro
The problem in 99% (not to say 100%) of cases is our code. Browsers have their differences and we have to make a code that suits everyone (or the most used).
– Rubico