When the javascript implementation check box exceeds the limit, a warning box is displayed. The javascript check box

Source: Internet
Author: User

When the javascript implementation check box exceeds the limit, a warning box is displayed. The javascript check box

This article describes how to bring up a warning box when the check box of javascript is exceeded. Share it with you for your reference. The specific implementation method is as follows:

<Html> <title> how to bring up a warning box when the javascript implementation 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 select" + max + "projects! "); Obj. checked = false ;}/// --> </script> <form name = "form"> select a maximum of two projects: <p> <input type = checkbox name = box1 onClick = "countChoices (this) "> select project 1 <p> <input type = checkbox name = box2 onClick =" countChoices (this) "> select project 2 <p> <input type = checkbox name = box3 onClick =" countChoices (this) "> select project 3 <p> <div> </FORM> </body>  

I hope this article will help you design javascript programs.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.