Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/02/2012, 09:02
miguelcalla
(Desactivado)
 
Fecha de Ingreso: octubre-2011
Mensajes: 164
Antigüedad: 12 años, 6 meses
Puntos: 1
habilitar /deshabilitar objetos de un form

hola,
tengo un script que valida un dato ingresado en <input type="text" name="rut"> de un formulario inscripcion,

el mismo <input type="text" name="rut"> se repito en varios formularios que ademas de rut tienen otros objetos (select+text+option+button etc.etc)
la llamada al script en cada form lo hago asi:
Código PHP:
Ver original
  1. <head>
  2. <script language="javascript" src="include/funciones.js" type="text/javascript"></script>
  3. </head>
  4. <body>
  5.      <input name="cedula" type="text" id="cedula" onChange="check_cedula(this.form);" />
  6. .
  7. .
  8. .
  9. </body>
donde funciones tengo el script js que valida:

Código Javascript:
Ver original
  1. function check_cedula(form){
  2.     var cedula = form.cedula.value;
  3.     array = cedula.split( "" );
  4.     num = array.length;
  5.         if ( num == 10 ){
  6.             total = 0;
  7.             digito = (array[9]*1);
  8.             for( i=0; i < (num-1); i++ ){
  9.                 mult = 0;
  10.                 if ( ( i%2 ) != 0 ) {
  11.                     total = total + ( array[i] * 1 );
  12.                 }else{
  13.                     mult = array[i] * 2;
  14.                     if( mult > 9 ){
  15.                         total = total + ( mult - 9 );
  16.                     }else{
  17.                         total = total + mult;
  18.                     }
  19.                 }
  20.             }
  21.    
  22.         decena = total / 10;
  23.         decena = Math.floor( decena );
  24.         decena = ( decena + 1 ) * 10;
  25.         final = ( decena - total );
  26.         if (( final == 10 && digito == 0 ) || ( final == digito )) {
  27.             alert( "La c\xe9dula ES v\xe1lida!!!" );
  28.             return true;
  29.         }else{ 
  30.             alert( "La c\xe9dula NO es v\xe1lida!!!" );
  31.             return false;
  32.         }
  33.     }else{
  34.         alert("La c\xe9dula no puede tener menos de 10 d\xedgitos");
  35.         return false;
  36.     }
  37.     }

mi duda es como habilitar /deshabilitar los objetos (select+text+option+button etc.etc) del formulario cuando check_cedula se Valida.