If you want to validate mutiple email entered into text box with comma seprated below is a simple function which can fullfil your need into javascript.Your just need to pass your comma seprated email into below function and rest of all it do itself.
Lets understand by an example :
Now below is the function to validate comma seprated email:
Happy coding :)
Chears
Lets understand by an example :
Suppose we have multiple comma seprated email ids and now we want to validate each email format should be correct like below -
var email = "phpsollutions@gmail.com, xyz@gmail.com, abc@yahoomail.com";
multipleEmailValidate(email);
Now below is the function to validate comma seprated email:
function multipleEmailValidate(email){ //In Email Variable Number Of Emails Comes With Comma Seprated eg(phpsollutions@gmail.com, xyz@gmail.com)
var filterforemail = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
if (email != ''){
var result = email.split(',');
for (var i = 0; i < result.length; i++){
if (result[i] != ''){
if(!filterforemail.test($.trim(result[i]))){
alert('Please check, ' + result[i] + ' email addresses not valid');
return false;
}
}
}
}
return true;
}
Happy coding :)
Chears