How to validate that at least one of two unrelated checkboxes is checked
I have a form with two unrelated checkboxes. How can I validate so that at least one of the checkboxes is checked? I have the HTML5 'required' for both checkboxes, but I think when I click submit, it sees those first and does nothing else.
So I tried this after removing 'required', but it's not seeing the second checkbox.
if($("#unsubscribe input[type=checkbox]").prop('checked') == false){ $('#checkboxAlert').show(); evt.preventDefault(); }
<form id="unsubscribe"> <input type="checkbox" id="group0001" name="group0001" value="on" class="check custom-class" required oninvalid="this.setCustomValidity('Please select at least one option to proceed')"><label for="subscription">Email Group 1 Communication</label> <input type="checkbox" id="groupsAll" name="groupsAll" value="on" class="check custom-class" required><label for="subscription">All Communication</label>