Gracias jcMouse! ya me he dado cuenta tras haber mas o menos acabado con el código....
.
Sé que es bastante cutre, pero es mi primera vez, aquí lo comparto a ver si alguien puede ayudarme a mejorarlo :
HTML
Código:
<script type="text/javascript">
function checkboxlimit(checkgroup, limit){
var checkgroup=checkgroup
var limit=limit
for (var i=0; i<checkgroup.length; i++){
checkgroup[i].onclick=function(){
var checkedcount=0
for (var i=0; i<checkgroup.length; i++)
checkedcount+=(checkgroup[i].checked)? 1 : 0
if (checkedcount>limit){
alert("Vous pouvez choisir seulement "+limit+" ")
this.checked=false
}
}
}
}
</script>
<FORM method=" post" NAME="thecode" action="http://google.com">
<p style="align:center"><input type="submit" id="btnSignUp" value="CODE" /> <input type=reset id=btnReset value=Reset></p>
<br>
<TABLE WIDTH=80% BORDER=1 CELLPADDING=2 CELLSPACING=2 background="modal2/101.png">
<COL WIDTH=36*>
<COL WIDTH=36*>
<COL WIDTH=36*>
<COL WIDTH=36*>
<COL WIDTH=36*>
<COL WIDTH=36*>
<COL WIDTH=36*>
<COL WIDTH=36*>
<COL WIDTH=36*>
<COL WIDTH=36*>
<TR>
<TD>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a1" VALUE="1" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(1)"><b>A</b> </P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a2" VALUE="2" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(2)"><b>C</b></P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a3" VALUE="3" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(3)"><b>C</b></P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a13" VALUE="4" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(4)"><b>0</b></P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a4" VALUE="5" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(5)"><b>E</b></P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a23" VALUE="6" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(6)"><b>9</b></P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a11" VALUE="7" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(7)"><b>1</b></P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a5" VALUE="8" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(8)"><b>S</b></P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a33" VALUE="9" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(9)"><b>Q</b></P>
</DIV>
</TD>
<TD WIDTH=10%>
<DIV ALIGN=CENTER>
<P><INPUT TYPE=CHECKBOX NAME="digit" id="a23" VALUE="10" STYLE="width: 0.12in; height: 0.12in" ONCLICK="chkcontrol(10)"><b>P</b></P>
</DIV>
</TD>
</TR>
// Etc. resto de tabla, no pego código ya que no puedo postear más de 10000 caracteres.
</TABLE>
</FORM>
<br>
<script type="text/javascript">
//Syntax: checkboxlimit(checkbox_reference, limit)
checkboxlimit(document.forms.thecode.digit, 10)
</script>
JavaScript
Código:
function formValidation(oEvent) {
oEvent = oEvent || window.event;
var txtField = oEvent.target || oEvent.srcElement;
var t1ck=true;
var msg=" ";
if(!document.getElementById("a1").checked ){ t1ck=false;}
if(!document.getElementById("a2").checked ){ t1ck=false;}
if(!document.getElementById("a3").checked ){ t1ck=false;}
if(!document.getElementById("a4").checked ){ t1ck=false;}
if(!document.getElementById("a5").checked ){ t1ck=false;}
if(!document.getElementById("a6").checked ){ t1ck=false;}
if(!document.getElementById("a7").checked ){ t1ck=false;}
if(!document.getElementById("a8").checked ){ t1ck=false;}
if(!document.getElementById("a9").checked ){ t1ck=false;}
if(!document.getElementById("a10").checked ){ t1ck=false;}
//alert(msg + t1ck);
if(t1ck){document.getElementById("btnSignUp").disabled = false; }
else{document.getElementById("btnSignUp").disabled = true; }
}
function resetForm(){
document.getElementById("btnSignUp").disabled = true;
var frmMain = document.forms[0];
frmMain.reset();
}
window.onload = function () {
var btnSignUp = document.getElementById("btnSignUp");
var btnReset = document.getElementById("btnReset");
var a1 = document.getElementById("a1");
var a2 = document.getElementById("a2");
var a3 = document.getElementById("a3");
var a4 = document.getElementById("a4");
var a5 = document.getElementById("a5");
var a6 = document.getElementById("a6");
var a7 = document.getElementById("a7");
var a8 = document.getElementById("a8");
var a9 = document.getElementById("a9");
var a10 = document.getElementById("a10");
var t1ck=false;
document.getElementById("btnSignUp").disabled = true;
a1.onclick = formValidation;
a2.onclick = formValidation;
a3.onclick = formValidation;
a4.onclick = formValidation;
a5.onclick = formValidation;
a6.onclick = formValidation;
a7.onclick = formValidation;
a8.onclick = formValidation;
a9.onclick = formValidation;
a10.onclick = formValidation;
btnReset.onclick = resetForm;
}
Gracias!