RE:Validar un email en Action Script
Publicado por
javi (1 intervención) el 06/05/2005 12:42:28
Es bastante completo. Además de validar el email comprueba que no te dejes vacios los campos.
function validate (address) {
if (address.length>=7) {
if (address.indexOf("@")>0) {
if ((address.indexOf("@")+2)<address.lastIndexOf(".")) {
if (address.lastIndexOf(".")<(address.length-2)) {
return (true);
}
}
}
}
return (false);
}
function formcheck () {
if ((((email == null)) || (email.length<1)) || (email == "ERROR! Direccion no válida")) {
email = "ERROR! La direccion no es válida";
action = "";
}
if (!validate(email)) {
email = "Direccion no valida";
action = "";
}
if ((((fname == null)) || (fname.length<1)) || (fname == "ERROR! Address not valid")) {
fname = "Nombre obligatorio";
action = "";
}
if ((((lname == null)) || (lname.length<1)) || (lname == "ERROR! Address not valid")) {
lname = "Nombre obligatorio";
action = "";
}
if ((validate(email)) && (email != "ERROR!") && (fname != "") && (lname != "")) {
action = "send";
loadVariablesNum (mailform, 0, "POST");
gotoAndPlay ("wait");
}
}