jQuery Regex not triggering if statement -
** edit ** regex not accepting lowercase. adding did trick. additionally had escape \ out again in order past part of regex work.
working 1 jquery following:
var email = new regexp('^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$', 'i');
i want verify email regex.
in current code see executing function not going if statement though regex matches.
$('#email').keyup(function() { var input = $(this).val(); var email = new regexp('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$'); if (email.test(input)) { console.log('inside if'); } console.log('outside if'); });
regex seems fine, need set case insensitive flag:
$('#email').keyup(function() { var input = $(this).val(); var email = new regexp('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$', 'i'); if (email.test(input)) { console.log('inside if'); } console.log('outside if'); });
Comments
Post a Comment