18/01/2006, 06:13
|
| Moderador extraterrestre | | Fecha de Ingreso: diciembre-2001 Ubicación: Madrid
Mensajes: 6.987
Antigüedad: 22 años, 4 meses Puntos: 61 | |
Prueba con esto: Código PHP: <html> <head> <script> chequear_si_tarjeta=['numero_tarjeta','fecha_caducidad'] function validar(esto){ mal=0; if(esto['pepe'][0].checked){ for(a=0;a<chequear_si_tarjeta.length;a++){ if(esto[chequear_si_tarjeta[a]].value==""){ texto=chequear_si_tarjeta[a].split("_").join(" "); alert("Debe rellenar "+texto); esto[chequear_si_tarjeta[a]].focus(); mal=1; } } } return (mal==0); } </script> </head> <body> <form action="javascript:alert('Enviado');" onsubmit="return validar(this)"> <input type="radio" name="pepe" value="1" />Con tarjeta<br /> <input type="radio" name="pepe" value="0" />Sin tarjeta<br /> Número tarjeta: <input type="text" name="numero_tarjeta" /><br /> <input type="text" name="fecha_caducidad" /><br /> <input type="submit" /> </form> Debes poner en el array chequear_si_tarjeta los name de los campos que debe comprobar.
Un saludo!
__________________ Cómo escribir
No hay pregunta tonta, sino tonto que quiere seguir en la ignorancia. |