Setting a limit to checkboxes

let checkedNumber = $w("#checkboxGroup1").value.length;
if(checkedNumber > 2 && checkedNumber < 5){
$w("#text1").show();
//$w("#text1").text = "You may proceed" // use a better message of course.
}

I Have similar question ,
I have more than 15 Checkbox , and i want to limit user to check only 3 Of them.

[ The checkbox are catagory of businesses e.g., Beauty salon, Bar, Tool station, Garding, Etc. Now i want user to only select 3 catg. ] currently i am using dropdown, but i feel checkbox would be more easier ]

whats the best solution? if checkbox then how can i limit to 3

You can simply do this by creating an event handler for your element using onChange. For this example, I set my max to 4 options and my element name is ‘coachingPriorities’. You will need to change the code below to your elements names:

let selected =
let coachingPrioritesSelectionTags

export function coachingPriorites_change ( event ) {
//limit to 4 selection max
let value = event . target . value
let length = value . length

console . log ( length ,  'coaching priority tags length' ) 

**for**  ( **var**  i  =  0 ;  i  <  length  -  1 ;  i ++) { 
    **if**  ( length  <=  4 ) { 
        selected  =  value 
    }  **else**  { 
        value  =  selected 
    } 
} 

console . log ( value ,  'coaching tags value' ) 
coachingPrioritesSelectionTags  =  value 
console . log ( coachingPrioritesSelectionTags ,  'coaching tag string value' ) 

setTimeout (() => { 
    $w ( '#coachingPriorites' ). value  = [] 
    $w ( '#coachingPriorites' ). value  =  value 
},  1 ) 

}