This article describes the method of using a javascript to implement a warning box that exceeds the limit. Share it for your reference. The specific implementation method is as follows:
<html><title>javascript implements a method to pop up a warning box if the check box exceeds the limit</title><body><SCRIPT LANGUAGE="JavaScript"><!--//function countChoices(obj) {max = 2;box1 = obj.form.box1.checked;box2 = obj.form.box2.checked;box3 = obj.form.box3.checked;count = (box1 ? 1 : 0) + (box2 ? 1 : 0) + (box3 ? 1 : 0);if (count > max) {alert("Sorry, you can only choose" + max + "items!");obj.checked = false; }}//--></script> <form name="form"> Please select up to 2 items: <p> <input type=checkbox name=box1 onClick="countChoices(this)"> Select item 1 <p> <input type=checkbox name=box2 onClick="countChoices(this)"> Select item 2 <p> <input type=checkbox name=box3 onClick="countChoices(this)"> Select item 3 <p> <div></div></FORM></body></html>I hope this article will be helpful to everyone's JavaScript programming.