0

I have a single Custom Field of type "Alphanumeric" and "CheckBox" with a check list which requires all boxes to be ticked before continuing.

I have set the field to Mandatory but this allows the form to be submitted with just one option selected.

Is there a way to set a CheckBox widget to require all boxes to be ticked? I don't really want to create lots and lots of Custom Fields to achieve this.

0

I dont think their is some setting in CiviCRM to set all the check box to required in a single custom group

But, you can create a javascript to set all the check box to Flag if one box is clicked

or you can check the value of the check box before form submit and alert the user

I guess this helps !!!

0

Using Jquery snippet below has solved my problem. First you will need to attach a javascript file to your Theme or Template so it will be loaded after JQuery, then hook into CRM.$ and away you go...

$( document ).ready(function() {
    CRM.$(function($) {
        $(".CRM_Profile_Form_Edit").on('submit', function (e) {
            if ($('input[id^="custom_XXX_"]:checked').length != $('input[id^="custom_XXX_"]').length) {
                $('#editrow-custom_XXX').addClass('crm-error crm-error-label');
                alert("Please ensure you tick all options.");
                return false;
            }
        });
    });
});

NOTE: Replace "XXX" above with the ID of your custom field in CiviCRM (You can find this out by using the "View Source" feature in your browser and looking at the HTML Input Element for the field in question).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.