Ver Mensaje Individual
  #2 (permalink)  
Antiguo 07/07/2010, 11:15
cronosmen
 
Fecha de Ingreso: junio-2008
Mensajes: 165
Antigüedad: 16 años, 9 meses
Puntos: 6
Respuesta: Validar que varios campos de texto no estén vacíos.

prueb añadiendo esto

Código Javascript:
Ver original
  1. <script language="JavaScript">
  2. function comprobar()
  3. {
  4. if novacio()==true;
  5. {
  6. document.frm.submit();
  7. }
  8. else
  9. {
  10. return false;
  11. }
  12. }
  13.  
  14. function noVacio()
  15.  {
  16.   var i;
  17.   var n = parseInt(document.frm.cantidad.value);
  18.   var bError = false;
  19.    
  20.   for (i = 0; i < n; i++)
  21.    {
  22.     bError = bError || (eval("document.frm.elemento" + i + ".value == ''"));
  23.     if (bError)
  24.      {
  25.       alert("Debe de introducir el asunto.");
  26.       eval("document.frm.elemento" + i + ".focus()");
  27.      return false;
  28.       break;
  29.      }
  30.      return true;
  31.     break;
  32.    }
  33.   }
  34. </script>