prova così:
codice:
function controllo(f) {
var ok1=false;
var ok2=false;
if (f.categoria.value!="") return true;
ok1=(f.categoriapre.value=="") ? false : true;
ok2=(f.sottocategoria.value=="") ? false : true;
if (!ok1) {
alert("Compilare il campo categoriapre.");
f.categoriapre.focus();
return false;
}
if (!ok2) {
alert("Compilare il campo sottocategoria.");
f.sottocategoria.focus();
return false;
}
return true;
}
da richiamare così:
codice:
<form name="f" onsubmit="return controllo(this);">
ciao