Ver Mensaje Individual
  #10 (permalink)  
Antiguo 17/01/2011, 13:54
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 9 meses
Puntos: 1012
Respuesta: Validar Formulario

vamos a hacer el código mas dinámico
Cita:
function validar(f) {
for (var i = 0, controles = f.elements; i < controles.length-1; i++) {
if (controles[i].value == '') {
window.alert("Debes completar todos los campos");
controles[i].focus();
return false;
}
}
}



<form action="ProcesoProducto.php" method="post" id="form" name="form" onsubmit="return validar(this);">
<input type="text" name="c1" id="c1" value="" />
<input type="text" name="c2" id="c2" value="" />
<input type="submit" size="25" value="Ingresar Producto" />