Jquery email validaiton not working
Hi;
I want this to validate if this is valid email AND it is not empty but it doesn't work!
What am I doing wrong?
Thanks
- $( "#txt_email" ).focusout(function() {
var pattern = new RegExp(/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/);
if(pattern.test($('#txt_email').val()) || $("#txt_email").val().length == 0 )
{
$("#txt_email").css("background-color", "white");
}
else
{
$("#txt_email").css("background-color", "pink");
}
});