Archive for January 2007

isEmail String prototype

Este prototipo es uno de tantos que valida emails:

String.prototype.isEmail = function() {
if (!this) {
return false;
}
var iChars = "*|,\":<>[]{}`’;()&$#% ";
for (var i = 0; i<this.length; 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:
mail="jaja@pua.es";
trace(mail.isEmail());