Ver Mensaje Individual
  #11 (permalink)  
Antiguo 20/07/2011, 12:08
Avatar de jesusvipze
jesusvipze
 
Fecha de Ingreso: julio-2011
Ubicación: León(España)
Mensajes: 11
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: Como validar email en formulario de recomendar web

Perdonad si soy pesado, pero a mi bola he logrado hacer que se validen los dos emails, no sólo uno.
Os dejo el código. He cambiado en el primer else de la validación del correo, en vez de dar true, obligar a la validación del otro correo:

<script language="JavaScript"
type="text/javascript">
function Validar_formulario_recomendar(theForm)<!--
{
if (theForm.nombre.value == "")
{
alert("Por favor rellena tu nombre");
theForm.nombre.focus();
return (false);
}
if (theForm.nombre.value.length < 2)
{
alert("Por favor rellena completamente tu nombre");
theForm.nombre.focus();
return (false);
}
if(theForm.nombre.value.replace(/ /g, '') == '')
{
alert("Debe Ingresar un nombre");
theForm.nombre.focus();
theForm.nombre.select();
return false;
}
if (theForm.email.value == "")
{
alert("Por favor rellena tu email");
theForm.email.focus();
return (false);
}
if (theForm.email.valuelength < 2)
{
alert("Por favor rellena correctamente tu email");
theForm.email.focus();
return (false);
}
if(theForm.email.value.replace(/ /g, '') == '')
{
alert("Debe Ingresar un email válido");
theForm.email.focus();
theForm.email.select();
return false;
}
if (theForm.destinatario.value == "")
{
alert("Por favor rellena el email a quien deseas recomendar esta web");
theForm.destinatario.focus();
return (false);
}
if (theForm.destinatario.valuelength < 2)
{
alert("Por favor rellena correctamente el email de tu amigo/a");
theForm.destinatario.focus();
return (false);
}
if(theForm.destinatario.value.replace(/ /g, '') == '')
{
alert("El email de destino no es válido");
theForm.destinatario.focus();
theForm.destinatario.select();
return false;
}
var exMail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(exMail.test(theForm.email.value)==false)
{
alert("El email introducido no es correcto");
theForm.email.focus();
theForm.email.select();
return false;
}
else
var exeMail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(exeMail.test(theForm.destinatario.value)==false )
{
alert("El email introducido no es correcto");
theForm.destinatario.focus();
theForm.destinatario.select();
return false;
}
else
{
return true;
}

}
//--></script>

Espero que os haya servido de ayuda.