0
I have a registration that validates the email event focusout in Input. That validation works perfectly. Now the need has arisen to validate multiple emails within the same Input, separating by ";" and how it could treat each email at once?
$("#cobrancaEmail").focusout(function () {
var valor = $("#cobrancaEmail").val();
//valida se o email é válido
if (validaEmailIE(valor)) {
$("#cobrancaEmail").css({ "border-color": "blue", "padding": "1px" });
$("#errocobrancaEmail").html("");
} else {
$("#cobrancaEmail").css({ "border-color": "red", "padding": "1px" });
$("#errocobrancaEmail").html("E-mail inválido!");
}
});
function validaEmailIE(email) {
var regex = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return regex.test(email);
}
What if you, instead of using ID (and thus can only pass 1 email per page to Jquery), use class? All emails that must be validated with the same class, could be passed to Jquery.
– Nathan Schroeder