JavaScript - validar formato email

 
Vista:

validar formato email

Publicado por sandra (1 intervención) el 14/05/2009 20:40:19
Hola a todos, agradezco toda la ayuda que puedan brindarme, tengo una función que valida un campo, el formato del correo; como puede tener una cuenta de correo también puede tener hasta cinco cuentas, tengo la función pero se demora muchisimo para validar y obviamente es tedioso para el usuario, esta es la función, como la puedo mejorar??? :

<script type="text/javascript">
var text=valor.value;
function validarEmail(valor)
{
var text=valor.value;
if (/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(text))
{
alert("ehhhhh");
return (true)
}
if (/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(text))
{
alert("ehhhhh");
return (true)
}
if (/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(text))
{
alert("ehhhhh");
return (true)
}
if (/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(text))
{
alert("ehhhhh");
return (true)
}
if (/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+;w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(text))
{
alert("ehhhhh");
return (true)
}
else
{
valor.focus();
alert("La dirección de email es incorrecta y entre correos debe estar separado por ';' punto y coma y sin espacios");
return (false);
}

}
</script>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:validar formato email

Publicado por Roman  (1 intervención) el 16/06/2009 07:42:19
<script type="text/javascript">
var text=valor.value;
function validarEmail(valor)
{
var text=valor.value;
if (/^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$/.test(text))
{
return (true)
}

else
{
valor.focus();
alert("La direccion de correo no es válida");
return (false);
}

}
</script>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:validar formato email

Publicado por eeee (1 intervención) el 19/01/2010 17:07:45
gsgsd
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar