Ver Mensaje Individual
  #3 (permalink)  
Antiguo 26/04/2012, 09:53
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Validación campo formulario array no me funciona

Agrego, también con:
Código Javascript:
Ver original
  1. var cuotas = document.getElementsByName('cuota[]');

Y luego recorrer el array()


Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <title>titulo</title>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5. <script type="text/javascript">
  6. //<![CDATA[
  7. function xxx(){
  8. var cuotas = document.getElementsByName('cuota[]');
  9. for(var i=0;i<cuotas.length;i++){
  10. if(cuotas[i].value == ""){
  11. alert('complete todas las cuotas');
  12. }
  13. }
  14. }
  15. //]]>
  16.  
  17. </head>
  18. <form name="formulario" action="#">
  19. <input name='cuota[]' type='text' value='000' size='5' />
  20. <input name='cuota[]' type='text' value='' size='5' />
  21. <input type="button" onclick="xxx();" value="verificar" />
  22. </form>
  23.  
  24. </body>
  25. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.