How to make all check boxes mandatory on a catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 10:46 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 12:40 PM
It works. Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 02:22 PM
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.
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;
}
}