http://es.geocities.com/juliovcmc83/pruebas/formulario.zip
y esta es la linea de código utilizada en el archivo:
Código ActionScript :
stop();
// --------------------------------------------------------------
// función que valida números
// --------------------------------------------------------------
String.prototype.isNumbers = function() {
if (this.length<1) {
return false;
}
for (i=0; i<this.length; i++) {
code = this.charCodeAt(i);
if (this.charAt(i) != " " && code<48 || code>57) {
return false;
}
}
return true;
};
// --------------------------------------------------------------
// valida mails
// --------------------------------------------------------------
String.prototype.isMail = function() {
if (this.indexOf("@")>0 && this.indexOf("@") == this.lastIndexOf("@")) {
if (this.lastIndexOf(".")>this.indexOf("@")+1 && this.lastIndexOf(".")<this.length-2) {
return true;
}
}
};
// --------------------------------------------------------------
// función que limpia los campos
// --------------------------------------------------------------
function limpiar() {
nom = "";
telefono = "";
mailFrom = "";
body = "";
mensaje_error =""
}
// --
nombre.tabIndex = 1;
tel.tabIndex = 2;
mail.tabIndex = 3;
msg.tabIndex = 4;
// --
nombre.borderColor = 0xAACD79;
tel.borderColor = 0xAACD79;
mail.borderColor = 0xAACD79;
msg.borderColor = 0xAACD79;
//
nombre.onSetFocus = function() {
mensaje_error = "";
nombre.backgroundColor = 0xFFE7D7;
nombre.borderColor = 0xFF8D42;
};
nombre.onKillFocus = function() {
nombre.backgroundColor = 0xF3FAED;
nombre.borderColor = 0xAACD79;
};
// --
tel.onSetFocus = function() {
mensaje_error = "";
tel.backgroundColor = 0xFFE7D7;
tel.borderColor = 0xFF8D42;
};
tel.onKillFocus = function() {
tel.backgroundColor = 0xF3FAED;
tel.borderColor = 0xAACD79;
};
//
mail.onSetFocus = function() {
mensaje_error = "";
mail.backgroundColor = 0xFFE7D7;
mail.borderColor = 0xFF8D42;
};
mail.onKillFocus = function() {
mail.backgroundColor = 0xF3FAED;
mail.borderColor = 0xAACD79;
};
//
msg.onSetFocus = function() {
mensaje_error = "";
msg.backgroundColor = 0xFFE7D7;
msg.borderColor = 0xFF8D42;
};
msg.onKillFocus = function() {
msg.backgroundColor = 0xF3FAED;
msg.borderColor = 0xAACD79;
};
//
bEnviar.onRollOver = bLimpiar.onRollOver=function () {
this.gotoAndPlay("sobre");
};
bEnviar.onRelease = function() {
if (nom.length<1) {
mensaje_error = "Por favor introduzca su nombre";
} else if (telefono.length<7 or telefono.isnumbers() == false) {
mensaje_error = "Por favor, introduzca un teléfono de contacto";
} else if (!mail.text.isMail()) {
mensaje_error = "Por favor, introduzca e-mail válido";
} else {
loadVariablesNum("form.php", 0, "POST");
limpiar()
mensaje_error = "Mensaje enviado con exito";
}
};
// --
bLimpiar.onRelease = function() {
limpiar();
};
