Streaming live at 10am (PST)

Form - multiple checkboxes, only one required

Hi all!
I have a group of checkboxes. Is that possible to make required at least one checkbox in the group? So, I want to apply “required” setting to a group of checkboxes, but not a single checkbox. If users don’t select at least one checkbox in the group I want to show an error message.

Please advise.

Did you find an answer for this? I’m looking for exactly the same solution

This would require custom code. I personally use formvalidation.io and this validator when this is needed. It’s a paid library. You might find an alternative.

@webdev

I tried a solution, with a script like this:
https://html.form.guide/checkbox/multiple-checkbox-validation-in-javascript/

but it doesn’t worked - I’ll guess according to the error and success messages in webflow.

Do you have an example how you did it?

Hello everyone!

Working on a client project and I had the same requirement. I think I’ve found a solution with the code bellow

<script>
 $(function(){
    var requiredCheckboxes = $('.class-of-a-div-that-wraps-checkboxes :checkbox[required]');
    requiredCheckboxes.change(function(){
        if(requiredCheckboxes.is(':checked')) {
            requiredCheckboxes.removeAttr('required');
        } else {
            requiredCheckboxes.attr('required', 'required');
        }
    });
});
</script>

Piter :webflow_heart:

Any tutorial or step by step instructions you care to share? Would be extremely helpful in completing the perfect product for a client of ours…