I have to validate a email field which can contain multiple email address separated by (;). The following 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 give the error message, even i insert 1 email address. I cannot find where i went wrong. any suggestions?
FYI: This is included in the form submission (onsubmit
)