Oke so i tested somethings out a bit.
I found the solution how to do it kinda easy.
On the top of the page code add
var selectedIndices
var maxSelections = 4
Then in the onChange of your checkboxgroup add this code.
if($w("#checkboxGroup1").selectedIndices.length > maxSelections ){
$w("#text1").text = "can't add any more selections"
$w("#checkboxGroup1").selectedIndices = selectedIndices
} else {
selectedIndices = $w("#checkboxGroup1").selectedIndices
var count = maxSelections - $w("#checkboxGroup1").selectedIndices.length
if(count === 0){
$w("#text1").text =`can't add any more selections`
} else {
$w("#text1").text =`u have still ${count} amount of selections`
}
}
This wil only let you select 4
Chenge the maxSelections to higher or lower the max selections.
the text1 element will show how many selections you have left
or display that there aren’t any left.
Hope this helps.
Kind regards,
kristof.