String.prototype.esMailCorrecto=function(){
st=this;
var mail=1;
var question,arroba,punto,espacio,ultimo;
question=st.lastIndexOf("?");
espacio=st.lastIndexOf(" ");
arroba=st.lastIndexOf("@");
punto=st.lastIndexOf(".");
ultimo=st.charAt(st.length-1);
if (ultimo!="." and question==-1 and espacio==-1 and arroba!=-1 and punto!=-1 and punto>arroba){
mail=1;
} else {
mail=0;
}
return mail;
}
// establecimiento del texto inicial de cada campo de texto
function inicio(){
nombre.text="";
email.text="";
telefono.text="";
direccion.text="";
cp.text="";
localidad.text="";
pais.text="";
comentario.text="";
}
inicio();
_root.onMouseUp=function(){
// limpiado y reseteo del campo de texto del nombre
if (Selection.getFocus()=="_level0.nombre" and nombre.text==""){
nombre.text="";
} else if (Selection.getFocus()!="_level0.nombre" and nombre.text==""){
nombre.text="";
}
// limpiado y reseteo del campo de texto del email
if (Selection.getFocus()=="_level0.email" and email.text==""){
email.text="";
} else if (Selection.getFocus()!="_level0.email" and email.text==""){
email.text="";
}
// limpiado y reseteo del campo de texto del telefono
if (Selection.getFocus()=="_level0.telefono" and telefono.text==""){
telefono.text="";
} else if (Selection.getFocus()!="_level0.telefono" and telefono.text==""){
telefono.text="";
}
// limpiado y reseteo del campo de texto de su direccion
if (Selection.getFocus()=="_level0.direccion" and direccion.text==""){
direccion.text="";
} else if (Selection.getFocus()!="_level0.direccion" and direccion.text==""){
direccion.text="";
}
// limpiado y reseteo del campo de texto de su codigo postal
if (Selection.getFocus()=="_level0.cp" and cp.text==""){
cp.text="";
} else if (Selection.getFocus()!="_level0.cp" and cp.text==""){
cp.text="";
}
// limpiado y reseteo del campo de texto de su localidad
if (Selection.getFocus()=="_level0.localidad" and localidad.text==""){
localidad.text="";
} else if (Selection.getFocus()!="_level0.localidad" and localidad.text==""){
localidad.text="";
}
// limpiado y reseteo del campo de texto del pais
if (Selection.getFocus()=="_level0.pais" and pais.text==""){
pais.text="";
} else if (Selection.getFocus()!="_level0.pais" and pais.text==""){
pais.text="";
}
// limpiado y reseteo del campo de texto del comentario
if (Selection.getFocus()=="_level0.comentario" and comentario.text==""){
comentario.text="";
} else if (Selection.getFocus()!="_level0.comentario" and comentario.text==""){
comentario.text="";
}
}
// acciones para los botones enviar y borrar
enviar.onRelease=function(){
if (!email.text.esMailCorrecto()){
trace("Ha de introducir una dirección de correo válida.")
} else {
trace("Nombre: "+nombre.text);
trace("email: "+email.text);
trace("telefono: "+telefono.text);
trace("direccion: "+direccion.text);
trace("Ciudad: "+cp.text);
trace("localidad: "+localidad.text);
trace("pais: "+pais.text);
trace("comentario: "+comentario.text);
}
}
borrar.onRelease=inicio;
No se muy bien donde le tengo que añadir la direccion a la que quiero que llegue la consulta, porque como ya he comentado soy novato en esto. Necesito un cable por que algo me dice que es una tonteria gorda.
