Ver Mensaje Individual
  #3 (permalink)  
Antiguo 18/02/2008, 12:11
CIBERDAVID
 
Fecha de Ingreso: marzo-2005
Ubicación: Barcelona
Mensajes: 192
Antigüedad: 19 años, 2 meses
Puntos: 1
Re: problemilla validando formulario

Perfecto, muchas gracias!! ya me anda bien. Solo te olvidate de poner 2 {, eso de boolean no se me habria ocurrido nunca jeje, pero weno, vamos aprendiendo poco a poco.

Código:
function validateName():Boolean {
if (nombre_ti.text.length<3 || isNaN(nombre_ti.text) == false) {
mensaje_txt.text = "Por favor, introduzca un nombre válido.";
nombre_ti.setStyle("color", 0xFF0000);
return false;  // Hubo un error, regresamos falso
}
else  { // Todo bien, regresamos verdadero
     return true;
}
}
function validateTf():Boolean {
if (telefono_ti.text.length != 9 || isNan(telefono_ti.text) == true) {
mensaje_txt.text = "Por favor, introduzca un teléfono válido.";
telefono_ti.setStyle("color", 0xFF0000);
return false;
}
else {
     return true;
}
}

function validateForm() {
     if(validateTf() && validateName()) // Es decir, si no hubo error
     {
           mensaje_txt.text = "Su consulta ha sido enviada, gracias.";
           registrationData.nombre = nombre_ti.text; 
           registrationData.telefono = telefono_ti.text; 
           registrationData.sendAndLoad("enviar_email.php", registrationData, "POST");
          clearForm();
     }
}