Ecco la soluzione JS corretta (mi permetto di spostare le chiamate dove ritengo stiano meglio e di correggere il codice HTML):
codice:
<script language="javascript" type="text/javascript">
function CtrlVal() {
var msg = document.frmMain.chk;
var count = 0;
for(var i=0; i<msg.length; i++) {
if(msg[i].checked) count++;
}
alert("sono selezionate "+count+" celle");
if(count == 0) {
alert("devi selezionare almeno un checkbox");
return false;
}
return true;
}
</script>
</head>
<body>
<form name="FrmMain" method="post" action="mdCtrlVal.asp" onsubmit="return CtrlVal();">
<input type='checkBox' name='chk' Value="1" />
<input type='checkBox' name="chk" Value="2" />
<input type='checkBox' name="chk" Value="3" />
<input type='checkBox' name="chk" Value="4" />
<input type='checkBox' name="chk" Value="5" />
<input type='checkBox' name="chk" Value="6" />
<input type='checkBox' name="chk" Value="7" />
<input type='checkBox' name="chk" Value="8" />
<input type='checkBox' name="chk" Value="9" />
<input type='submit' value='invia' />
</form>
</body>