Convertigo Public Knowledge base

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
(()=>{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:

 

(c) Convertigo 2023 https://www.convertigo.com