Ver Mensaje Individual
  #6 (permalink)  
Antiguo 19/07/2011, 15:28
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

Muchas gracias por tu interés. Voy a probar la función que tal gentilmente me has buscado. En efecto tienes toda la razón, sólo es posible revisar que la dirección de correo electrónico tenga una estructura correcta. La única manera de comprobar que el visitante está introduciendo su email , es el método de confirmación opt-in.

(Te envian un email a tu bandeja y debes confirmar el email desde tu correo antes de que se envíe el formulario...ejem , esto si que tiene que ser supercomplicado...)



Respecto a lo de los espacios en blanco , he logradpo que me funcione y contaré cómo , por si a alguien le sirve tu solución o la mía. He añadido un ¿parámetro? o como se llame que no se, que es replace. La línea añadida para validar los espacios en blanco está señalada en rojo:


<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;
}

{
return (true);
}
}
//--></script>
<form style="background-color: rgb(204, 184, 203);"
action="recomendanos.php" method="post"
onsubmit="return Validar_formulario_recomendar(this)"
name="recomendanos" id="recomendanos" text-align=""
center="" background-color="">
<div
style="text-align: left; background-color: rgb(204, 184, 203);"><span
style="font-family: Comic Sans MS;">Tu nombre:</span><br>
</div>
<input name="nombre" size="18"><br>
<div style="text-align: left;"><span
style="font-family: Comic Sans MS;">Tu email:</span><br>
</div>
<input name="email" size="18"
onkeypress="return Pulsar(event,this)"><br>
<div style="text-align: left;"><span
style="font-family: Comic Sans MS;">Email de tu
amigo:</span><br>
</div>
<input name="destinatario" size="18"><br>
<br>
<input value="Enviar a un amigo" name="B1"
type="submit">
<span style="font-family: Century Gothic;"><span
style="text-decoration: underline;"><br>
<br>
</span></span></form>
</td>