Ciao Andrea,
dopo alcune prove, basandomi sul codice che mi hai suggerito, ho creato quest'altro codice molto più elementare (ad ogni click sulle checkbox, si esegue un conteggio delle caselle selezionate. Se il numero è superiore al limite, cioè 4, appare il messaggio di alert).


Riporto qui sotto il semplice script:


<script type="text/javascript">
function checkboxlimit(){
cont = 0;
var box1 = document.getElementById('tuocarattere').checked;
var box2 = document.getElementById('tuocarattere_1').checked;
var box3 = document.getElementById('tuocarattere_2').checked;
var box4 = document.getElementById('tuocarattere_3').checked;
var box5 = document.getElementById('tuocarattere_4').checked;
var box6 = document.getElementById('tuocarattere_5').checked;
var box7 = document.getElementById('tuocarattere_6').checked;
var box8 = document.getElementById('tuocarattere_7').checked;
cont = box1 + box2 + box3 + box4 + box5 + box6 + box7 + box8;
if (cont > 4) {alert("You can only select a maximum of 4 checkboxes!");}
}
</script>


Questo nel BODY:


<input type="checkbox" name="tuocarattere" id="tuocarattere" value="romantico" class="checkbox" onclick="checkboxlimit()" />romantic</input>

<input type="checkbox" name="tuocarattere_1" id="tuocarattere_1" value="ribelle" class="checkbox" onclick="checkboxlimit()" />rebel</input>

<input type="checkbox" name="tuocarattere_2" id="tuocarattere_2" value="passionale" class="checkbox" onclick="checkboxlimit()" />passionate</input>

<input type="checkbox" name="tuocarattere_3" id="tuocarattere_3" value="timido" class="checkbox" onclick="checkboxlimit()" />timid</input>

ecc..


Così funziona, (anche se si potrebbe migliorare usando un ciclo for-next), però ora ci vorrei aggiungere il codice che, appena selezionata la quinta checkbox, e subito dopo apparso il messaggio, automaticamente si deseleziona l'ultima checkbox selezionata, quella che eccede il limite...Come si può fare?