if any checkbox is checked in a checkbox array
Hello and thank you to those who have helped me in the past. I'm having a brain issue in reversing logic that I have successfully used in the past.
What I need to do:
I have a checkbox array. If
any of the checkboxes (
freeform_ch_cla_course_preferences_courses_001_1 -
freeform_ch_cla_course_preferences_courses_001_5) are checked, I would like to addClass to a textarea (id="
101").
Unfortunately, the code I have below, only works to toggle the validation.
Thank you for any help in advance.
Peter T
-
- $("#freeform_ch_cla_course_preferences_courses_001_1, #freeform_ch_cla_course_preferences_courses_001_2, #freeform_ch_cla_course_preferences_courses_001_3, #freeform_ch_cla_course_preferences_courses_001_4, #freeform_ch_cla_course_preferences_courses_001_5").change(function() {
- var checked =this.checked
- $("#101").addClass("required error", checked);//large_field_007
- $("#student-activities").show();
- if(!checked){
- $("#101").removeClass("required error", checked);//large_field_007
- $("#101").val("");//large_field_007
- $("#student-activities").hide();
- }
- }).change();