For example, jscheckbox limits the number of checkboxes to six.
Today, when I was working on a project, I encountered a problem. I need to display multiple checkbox check boxes, but I can only select up to six. After debugging for a long time, I finally came out. The Code is as follows:
<SCRIPT LANGUAGE="JavaScript"> var c=0,limit=6; function doCheck(obj) { obj.checked?c++:c--; if(c>limit){ obj.checked=false; alert("over"); c--; } } </SCRIPT>
The result is as follows:
Js question: How can I limit the number of checkboxes that cannot be submitted?
Function selAll (){
Var delmessage = document. getElementsByName ("delimiter ");
Var len = delmessage. length;
For (var I = 0; I <len; I ++ ){
If (len <7 ){
} Else {}
}
How does JS control the check box selection times?
You can add a counter.
<Script>
Var s = 0;
Function checkbox_max (obj, num ){
If (s> = nmu)
{
Alert ("your selections have exceeded! ");
// Operations that exceed the selected number of times
}
Else
{
S ++;
// What should I do if it is not too old?
}
}
</Script>