Validate email from string delimited by semicolon


function validateEM(textemail) {
var mensaje = "";
var result="";
var value = textemail;
if (value != "") { value = $.trim(value); value = value.toLowerCase(); var emails = value.split(";"); for (i = 0; i < emails.length; i++) { var item = $.trim(emails[i]); if (!validateEmail(item)) { mensaje += ", " + emails[i]; } } if (mensaje != "") { if (mensaje.startsWith(",")) { mensaje = mensaje.substring(1); } if (mensaje == " ") { result = "Error, email by* ; *"; } else { result = "Fail Emails, " + mensaje; } if (result != "")
alert(result); }
}
}
function validateEmail(field) {
var regex = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}$/;
return (regex.test(field)) ? true : false;
}
Ebook Download
View all
Learn
View all