samedi 12 septembre 2015

Jquery Validation Required for Multiple Checkbox with same ID

I had a "I AGREE" form with XX fields with checkboxes.

This fields come from a SQL table and will be selected or created by the admin.

The Admin can create as many as he wants.

All checkboxes must be required.

There is any way to check and require all checkboxes with one Jquery Rule?

        "agree[]": {
            required : true,
        },


<form class="form-horizontal" id="form" role="form" action="#" method="POST" autocomplete="off">

      <div class="form-group has-feedback">
        <label class="col-lg-4 col-md-4 col-sm-3 col-xs-3 control-label mLabelText"></label>
        <div class="col-lg-8 col-md-8 col-sm-8 col-xs-8 form-space checkbox">
        <label>
        <input type="checkbox" id="agree1" name="agree[]" value="1">
        CONDITION 1  
        </label>  
        </div>
      </div>   

      <div class="form-group has-feedback">
        <label class="col-lg-4 col-md-4 col-sm-3 col-xs-3 control-label mLabelText"></label>
        <div class="col-lg-8 col-md-8 col-sm-8 col-xs-8 form-space checkbox">
        <label>
        <input type="checkbox" id="agree2" name="agree[]" value="2">
        CONDITION 2  
        </label>  
        </div>
      </div>  

I try this - but Jquery only requires ONE checkbox, not All.

**** Because I need a "dynamic rule" for all checkboxes - I think this will be the best way to do this..

tks a lot!




Aucun commentaire:

Enregistrer un commentaire