How to make all check boxes mandatory on a catalog item

Kalyani35
Tera Guru

Hi experts,

We have a catalog item with 3 checkboxes one after another.

Generally if there is a group of checkboxes then by default selection of at least one checkbox becomes mandatory.

But Client wants all of these 3 checkboxes to be mandatory. 

Is there any OOB way to achieve this.

6 REPLIES 6

It works. Thank you

edward_vogel
Tera Contributor

If all 3 of the available checkboxes are required, then why not just use "selection required" on the variable? Otherwise you could also create a UI policy, without a condition, to make the 3 checkbox variables mandatory.

 

edward_vogel_0-1692822403396.png

The only reason to write a client script to handle the behavior on multiple checkboxes is if you require at least one or more selected, but not all. Then you would use something like this:

function onSubmit() {

    //At least one checkbox must be ticked
    var good = g_form.getBooleanValue('var_good');
    var cheap = g_form.getBooleanValue('var_cheap');
    var fast = g_form.getBooleanValue('var_fast');

    if (!good && !cheap && !fast) {
        alert('At least one checkbox must be selected.');
        return false;
    }

}