mercredi 12 septembre 2018

jquery validation message for checkboxes not working

I need to get a message as "This field is required" if no checkbox has been checked.

view:

<div style="width: 100%;">
                <label class="headlabel" id="passLable" name="passLable">Category List : <strong>*</strong></label>
                <div style="width: 100%;" class="form-group px-3">
                    <?php foreach ($cat as $data2) { ?>
                        <div class="form-check px-2" style="display: inline-block; margin-right: 20px;">
                            <input type="checkbox" class="form-check-input" value="<?php echo $data2->id ?>" name="cat[]" id="category">
                            <label class="form-check-label"
                                   style="padding-left: 10px;"><?php echo $this->lang->line($data2->cat_name); ?> </label>
                        </div>
                    <?php } ?>
                </div>
            </div>

rules js validation:

rules: {
'cat[]' : {
            required : true
          }
       }

Message js validation

 messages: {
            'cat[]' : {
                required : "plase fill this."
            },
        },

This already show the checkboxes in red colour but no message is shown. How can I get the validation message.




Aucun commentaire:

Enregistrer un commentaire