I need to check an email field, which can contain multiple email addresses separated by (;). Below is the code I used
$("body").find(".reqEmail").filter(function(){ var regex = new RegExp(/^[_A-Za-z0-9-]+[^(),:;<>\\[\\]@]*@[^(),:;<>\\[\\]@]*(\\.[A-Za-z]{2,})+$/);///^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; var email=$(this).val() if(regex.test(email)==false){ e.preventDefault(); $(this).css("border","solid 1px red"); $(this).parent().find("#ReceAppEmail").html("Invalid Email!!"); } else{return true;} });
It always gives an error message, even I insert 1 email address. I can not find where I was wrong. any suggestions?
FYI: This is included in the submission form ( onsubmit )
source share