Ver Mensaje Individual
  #7 (permalink)  
Antiguo 27/03/2016, 21:39
sarrhen
 
Fecha de Ingreso: mayo-2013
Ubicación: San Vicente
Mensajes: 127
Antigüedad: 10 años, 11 meses
Puntos: 1
Respuesta: Validar Input fields dinamicos

lo he soluciona pero a media ya que solo un input valida y muestra la alerta lo estoy haciendo con jquery y jquery.validate y como hacer para que me valide los que el usuario utilize siempre y cuando este no deje campos vacios

Código HTML:
Ver original
  1. <form id="myform" name="myForm" action="" method="POST">
  2.    
  3.      <label for="PASIVOS">Ingreso de datos</label>
  4.       <div class="input_fields_wrap1">
  5.     <input class="add_field_button1" type="button" value="+ Agregar" />
  6.         </div>

Código Javascript:
Ver original
  1. $(document).ready(function() {
  2.      
  3.     var max_fields      = Infinity; //maximum input boxes allowed
  4.     var wrapper1             = $(".input_fields_wrap1");
  5.     var add_button1        = $(".add_field_button1"); //Add button
  6.  
  7.     var x = 1; //initlal text box count
  8.     $(add_button1).click(function(e){ //on add input button click
  9.         e.preventDefault();
  10.         if(x < max_fields){ //max input box allowed
  11.             x++; //text box increment
  12.             $(wrapper1).append('<div>Producto <input type="text" name="Producto[]"/> Precio <input type="text" name="Precio[]"/>  Cantidad <input type="text" name="Cantidad[]"/><a href="#" class="remove_field">Quitar</a></div>'); //add input box
  13.         }
  14.     });
  15.  
  16.      $(wrapper1).on("click",".remove_field", function(e){ //user click on remove text
  17.          
  18.        e.preventDefault(); $(this).parent('div').remove(); x--;
  19.     })
  20.  
  21.  $('#myform').validate({
  22.     rules: {
  23.        "Producto[]": {
  24.     required: true,
  25.  
  26.   },
  27.   "Precio[]": {
  28.     required: true,
  29.    
  30.   },
  31.   "Cantidad[]": {
  32.     required: true,
  33.    
  34.   },
  35.     }
  36. });
  37.    
  38. });