This article describes how to detect and limit the number of check boxes in JavaScript. it involves javascript checks and operations related to check boxes, which is very simple and practical, for more information about how to detect and limit the number of check boxes in JavaScript, see the following example. Share it with you for your reference. The details are as follows:
Here, you can use JavaScript to determine whether to select the check box or limit the number of check boxes. this is a useful JavaScript form judgment example. it may be confusing to check whether the check box is selected, this code helps you solve the problem.
The running effect is as follows:
The code is as follows:
Check whether the check box is selectedScript var check_num = 0; function check () {if (event. srcElement. checked = true) check_num ++; else check_num --; if (check_num> 3) {alert ("a maximum of three! "); Event. srcElement. checked = false; check_num -- ;}} script
You can select only three check boxes.
I hope this article will help you design javascript programs.