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


0