Good morning, I'm developing a form where I have a "username" field, in this field I use this RegExp("^[0-9a-zA-Z \b]+$")
, it works perfectly, however when I use the TAB key to move to the next field it does not work! I've already tried using \t
, but to no avail.
Any issues?
Follow the code below:
$('#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;
}
});