Javascript: A simple way when validating forms to ensure at least one checkbox is checked
Check so at least one checkbox on your form is checked before it's allowed to submit:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $("#main_form").on('submit',function(e){ if ( $("input[type='checkbox']:checked").length > 0) { } else { e.preventDefault(); alert("Please check at least one list you wish to be included in."); return false; } return true; }); |