Olá galera,
Estou com uma dúvida.....
Consigo validar um campo de email com JS, porém não consigo validar se forem dois campos de email, por exemplo:
<form action="#" method="post" name="form">
Email 1: <input type="text" name="email1">
Email 2: <input type="text" name="email2">
<input type="submit" value="OK" onclick="validarEmail(this);">
</form>
function validarEmail(form){
var test = document.form.emai1l.value;
if (email1 = (document.form.email1.value.search("@") == -1 || document.form.email1.value.search("[.*]") == -1)){
alert("Digite o email antigo corretamente");
document.form.email1.focus();
test = false;
return(test);
}
var ok = document.form2.paraEmail.value;
if (email2 = (document.form.email2.value.search("@") == -1 || document.form.email2.value.search("[.*]") == -1)) {
alert("Digite o email novo corretamente");
document.form.email2.focus();
ok = false;
return(false);
}
}
Ele mostra o alert mais passa para a página subsequente...
Podem me ajudar??
Validaçao Do Campo Email
Started By nannynha, 17/08/2007, 10:53
2 replies to this topic
#1
Posted 17/08/2007, 10:53
#2
Posted 17/08/2007, 14:19
Faz isso em JS amigo...
Atenciosamente.
<script language="JavaScript" type="text/javascript"> <!-- function Validateemails(theForm) { var strValue = theForm.email1.value; var strFilter = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i; if (!strFilter.test(strValue)) { alert("COLOQUE EMAIL VALIDO..."); return false; } var strValue = theForm.email2.value; var strFilter = /^([0-9a-z]([-.\w]*[0-9a-z])*@(([0-9a-z])+([-\w]*[0-9a-z])*\.)+[a-z]{2,6})$/i; if (!strFilter.test(strValue)) { alert("COLOQUE EMAIL VALIDO...2"); return false; } return true; } //--> </script> <form name="emails" method="post" action="" enctype="text/plain" onsubmit="return Validateemails(this)"> <input type="text" id="email1" size="21" name="Email" value="" maxlength="70"> <input type="text" id="email2" name="email2" value="" maxlength="70"> <input type="submit" name="btn" value="Testar"> </form>
Atenciosamente.
Visitem também >>>> Web Aplicações
Visitem também >>>> Portal Masters - Fórum
Visitem também >>>> Portal Masters - Fórum
#3
Posted 20/08/2007, 09:58
Valeu, obrigada!!!
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)