I have a set of checkboxes in my HTML that look like this:
div class="grid_7"> <fieldset class="age shadow_50"> <label class="legend">Age Group</label> <div class="formRow checkbox"> <input id="" type="checkbox" name="age[]" value="child" /> <label>Child</label> </div> <div class="formRow checkbox"> <input id="" type="checkbox" name="age[]" value="30's" /> <label>30s</label> </div> <div class="formRow checkbox"> <input id="" type="checkbox" name="age[]" value="60's" /> <label>60's</label> </div> <div class="formRow checkbox"> <input id="" type="checkbox" name="age[]" value="teen" /> <label>Teen</label> </div> <div class="formRow checkbox"> <input id="" type="checkbox" name="age[]" value="40's" /> <label>40's</label> </div> <div class="formRow checkbox"> <input id="" type="checkbox" name="age[]" value="70's" /> <label>70's</label> </div> <div class="formRow checkbox"> <input id="" type="checkbox" name="age[]" value="20's" /> <label>20's</label> </div> <div class="formRow checkbox"> <input id="" type="checkbox" name="age[]" value="50's" /> <label>50's</label> </div> </fieldset> </div>
I set a check rule in my controller, which (in my opinion) ensures that the checkbox is checked,
$this->form_validation->set_rules('age[]', 'age group', 'required|trim');
When testing this, however, I get an error message forever with the name age []. I just want to check that age [] is not empty.
How can i achieve this?
source share