Skip to main content
Skip table of contents

Limit the number of selectable options

In a PWA form, if you want to limit the number a user can click checkboxes, you have to use a Business Logic:

Business Logic

JS
(()=>{var max=3;if(<checkbox1>.filter((e)=>{return e.selected == true}).length > max){console.log("max options selected reached!");<checkbox1>=JSON.parse(JSON.stringify(page["local"]["__c8o_max_check"]));window.setTimeout(()=>{alert("You can not select more than "+max+" options.")},250);}else{console.log("Max not reached!");page["local"]["__c8o_max_check"]=JSON.parse(JSON.stringify(<checkbox1>))}})()

<checkbox1> is the technical name of the Checkbox component.

This will result in:

3 maximum checkboxes

the max variable sets the max number of checkboxes that can be checked.

console.log and alert are optional.

Here is the form to import in your No Code Studio environment:

max_options.c8oforms

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.