Grazie cavicchiandrea e ottima la sintesi dei controlli che mi hai fornito.
Grazie ai tuoi suggerimento ho ridotto il codice in questo modo e funziona egregiamente
codice:
function check_valid(theForm) {
for (i=0; i < theForm.elements.length; i++) {
if (theForm.elements[i].name == "privacy") {
if (theForm.elements[i].checked == false) {
alert(theForm.elements[i].name + ": campo non spuntato");
theForm.elements[i].value = "";
theForm.elements[i].focus();
return false;
}
} else if (theForm.elements[i].value == "" && theForm.elements[i].className == "si") {
alert (theForm.elements[i].name + ": campo vuoto non accettabile");
theForm.elements[i].value = "";
theForm.elements[i].focus();
return false;
}
}
Per il checkbox uso il name anzichè il type perchè, almeno in questo momento, non ho intenzione di controllare altri eventuali checkbox.