I'm just making some form validation with jQuery, this is the part for the email:
var re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
var email = $('#user_email');
$('#user_email').on('keyup change', function() {
if ((email.val().length <= 6) && (re.test(email.val()))) {
$('#alert_user_email').text('Email cannot be blank or invalid formation');
submit_btn.disabled = true;
$('#alert_user_email').show();
} else {
$('#alert_user_email').text('');
submit_btn.disabled = false;
$('#alert_user_email').hide();
}
});
But for some reason it isn't working, everything works fine if I remove the && re.test
stuff from the if
statement but isn't working as intended, any enlightenment would be great!