Well, you can write some messy function for that...
like,
function check_checkboxes() {
global $allthenames,...;
$x = 0;
if ($checkbox_name) {
$x++
}
... do this for all the names
//close function
}
Or just do exacly that without functions,
and then check if x < 3...
BTW, don't mind of the function... I create function for everything anyway 🙂