Artikel ini menjelaskan metode menggunakan JavaScript untuk mengimplementasikan kotak peringatan yang melebihi batasnya. Bagikan untuk referensi Anda. Metode implementasi spesifik adalah sebagai berikut:
<Html> <title> JavaScript mengimplementasikan metode untuk memunculkan kotak peringatan jika kotak centang melebihi batas </iteme> <daster> <script language = "javascript"> <!-// function countchoices (obj) {max = 2; box1 = obj.Form.box1.checked; box2 = Obj.chform. (box1? 1: 0) + (box2? 1: 0) + (box3? 1: 0); if (count> max) {waspada ("Maaf, Anda hanya dapat memilih" + max + "item!"); 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 Butir 3 <p> <div> </div> </form> </body> </html>Saya harap artikel ini akan membantu pemrograman JavaScript semua orang.