Ver Mensaje Individual
  #6 (permalink)  
Antiguo 08/05/2010, 10:16
Avatar de _cronos
_cronos
 
Fecha de Ingreso: abril-2010
Mensajes: 135
Antigüedad: 14 años
Puntos: 1
Respuesta: Bloquear campos

Bueno pues he estado probando a ver cómo podía hacerlo pero no me ha salido aver si alguien con más conocimientos puede ayudarnos xD. Yo conseguí esto (la consola de errores me pone missing formal argument cuano ejecuto la 2ª función y undefined en la primera :S)

Código HTML:
Ver original
  1.  <head>
  2.   <title>A</title>
  3.  </head>
  4.  <body>
  5.   <script>//más abajo//</script>
  6.   <form name='f1' id='f1' method='post' action=''>
  7.     Primer input<input type='text' id='t1' onkeyup='mostrar(t1, div1)' onkeydown='mostrar(t1, div1)'>
  8.     Segundo input<input type='text' id='t2' onkeyup='mostrar(t2, div2)' onkeydown='mostrar(t2, div2)'>
  9.     <div style='visibility:hidden;' id='div1'>
  10.     Primer input (oculto)<input type='text' id='t1.1'>
  11.     </div><div style='visibility:hidden;' id='div2'>
  12.     Segundo input (oculto) <input type='text' id='t2.1'>
  13.     </div>
  14.     <input type='button' onClick='comprobar(t1, t1.1, div1, t2, t2.1, div2)' value='Enviar'>
  15.   </form>
  16.  </body>
  17. </html>

Código Javascript:
Ver original
  1. <script type='text/javascript'>
  2.    function mostrar(a, b){
  3.     if(document.getElementById('a').value!=''){
  4.      document.getElementById('b').style.visibility = 'visible';
  5.     }else{
  6.      document.getElementById('b').style.visibility = 'hidden';
  7.     }
  8.    }
  9.    
  10.    function comprobar(a1, a2, a3, a4, a5, a6){
  11.     if(document.getElementById('a3').style.visibility = 'visible' && document.getElementById('a1').value!='' && document.getElementById('a2').value=''){
  12.      alert('Debe rellenar todos los campos');
  13.      return false;
  14.     }else{
  15.       return true;
  16.     }  
  17.     if(document.getElementById('a6').style.visibility = 'visible' && document.getElementById('a4').value!='' && document.getElementById('a5').value=''){
  18.      alert('Debe rellenar todos los campos');
  19.      return false;
  20.     }else{
  21.       return true;
  22.     }
  23.    }
  24.   </script>

Siento no poder darte el código válido.
Saludos