How to make Checkbox selection mandatory

Snow Angel
Tera Expert

Hello,

Requirement is to have at least one or more selected before submitting form. How can I make this Catalog Item checkboxes mandatory.

"Required Provision" is a container so can't be made required.

"Please select:" is a label, and if I make the first option Mandatory then it conflicts with a UI Policy where if the last option is selected, every option above goes read-only. Same for the first option, if it is selected everything below gets read only. (pasted below) The right side of this container is reserved for other fields that pops depending on selection of one of these fields. Please help. Is this going to be a Catalog Client Script?

 

SnowAngel_1-1716404625402.png

SnowAngel_0-1716406317777.pngSnowAngel_1-1716406369761.png

 

I have tried below Catalog Client Script but even after selecting one checkbox, its not letting me submit the form. What's wrong with this approach?

function onSubmit() {
    var checkbox1 = g_form.getControl('opt_physical_access').checked;
    var checkbox2 = g_form.getControl('opt_it_remote_access').checked;
    var checkbox3 = g_form.getControl('opt_it_laptop').checked;
    var checkbox4 = g_form.getControl('opt_it_telephone').checked;
    var checkbox5 = g_form.getControl('opt_it_mobile').checked;
    var checkbox6 = g_form.getControl('no_physical_or_logical_access_required').checked;

    if (!checkbox1 && !checkbox2 && !checkbox3 && !checkbox4 && !checkbox5 && !checkbox6) {
        g_form.addErrorMessage("Please select at least 1 choice under Required Provisioning section");
        return false; // Prevent form submission if no checkboxes are selected
    }

    return true; // Allow form submission if at least one checkbox is selected
}


 

5 REPLIES 5

Apurva22
Tera Contributor

if there are two labels and and each has check boxes any tick in any check box doesnot work