NEW to wix coding, how to add limit on check boxes?

Hi,
Connect the checkboxes to the same onchange event function.
The function should look something like this:

export function checkbox1_change(event, $w) {
	let counterOfChecked = 0;
	let idOFUnChecked = [];
	for (let i = 1; i < 6; i++) {
		if ($w(`#checkbox${i}`).checked) {
			counterOfChecked++;
		} else {
			idOFUnChecked.push(i);
		}
	}
	if (idOFUnChecked.length === 2) {
		idOFUnChecked.forEach((id) => {
			$w(`#checkbox${id}`).disable();
		});
	} else {
		idOFUnChecked.forEach((id) => {
			$w(`#checkbox${id}`).enable();
		});
	}
}

Please update in your progress.
Roi.