Este prototipo es para la clase string y lo que hace es muy simple recibe una cadena y verifica si es una dirección de mail correcta.
Actionscript:
-
String.prototype.isEmail = function() {
-
if (!this) {
-
return false;
-
}
-
var iChars = "*|,\":<>[]{}`';()&$#% ";
-
for (var i = 0; i
-
if (iChars.indexOf(this.charAt(i)) != -1) {
-
return false;
-
}
-
}
-
if (this.indexOf("@") == -1) {
-
return false;
-
}
-
if (this.indexOf(".") == -1) {
-
return false;
-
}
-
return true;
-
};
Ejemplo de uso
Actionscript:
-
String.prototype.isEmail = function() {
-
if (!this) {
-
return false;
-
}
-
var iChars = "*|,\":<>[]{}`';()&$#% ";
-
for (var i = 0; i
-
if (iChars.indexOf(this.charAt(i)) != -1) {
-
return false;
-
}
-
}
-
if (this.indexOf("@") == -1) {
-
return false;
-
}
-
if (this.indexOf(".") == -1) {
-
return false;
-
}
-
return true;
-
};
-
//Uso:
-
comprobar_btn.onRelease = function() {
-
if (mail_txt.text.isEmail() == false) {
-
status_txt.text = "el email es invalido";
-
} else {
-
status_txt.text = "el email es correcto";
-
}
-
};