jQuery Validation - adding dynamically new rules if new elements are added?

27 views Asked by At

Suppose I have something like this:

enter image description here

<input type="text" class="..." placeholder="Title" name="box[0][title]" value="">
<input type="text" class="..." placeholder="Description" name="box[0][descrip]" value="">

If a second 'box' was added it would be:

 <input type="text" class="..." placeholder="Title" name="box[1][title]" value="">
 <input type="text" class="..." placeholder="Description" name="box[1][descrip]" value="">

How can I add validation if more boxes are added?

jQuery('form').validate({


          rules: {
               'box[0][title]': {
                       required: true
                         },
              'box[0][descrip]': {
                       required: true
                         },
                    //How can I add rules if a second box is added?
0

There are 0 answers