I have written following function in jQuery:
<script> function validateAppliesTo() { if ($("#collapseCat_row input:checkbox:checked").length > 0) { return true; } else { swal({ title: "", text: "Please select any course for which the fee should apply! " }); return false; } if ($("#accordion_cat input:checkbox:checked").length > 0) { return true; } else { swal({ title: "", text: "Please select any category! " }); return false; } return true; } </script> The above code works fine for #course_condition_row but does not works for #accordion_cat.
In html
<div class="panel panel-default"> <div class="panel-heading"> <h5 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion_cat" href="#collapseCat">Category</a> </h5> </div> <div id="collapseCat" class="panel-collapse collapse in"> <div class="panel-body"> <input name="student_category[]" class="cls_categories" id="General" value="3" type="checkbox"> General<br> <input name="student_category[]" class="cls_categories" id="Reserved" value="4" type="checkbox"> Reserved<br> </div> </div> </div> I want to validate the form. If any checkbox is not selected in category accordion then it should return false.
accordion_catid in your html