Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script> </head> <body> <div id="checkList"> <input id="checkbox1" type="checkbox" name="one" value="1" /> <input id="checkbox2" type="checkbox" name="two" value="2" /> <input id="checkbox3" type="checkbox" name="thr" value="3" /> </div> <input type="button" id="btnCheck" value="Check" /> <script type="text/javascript"> $(function() { $("#btnCheck").click(function() { let checked = $("#checkList input[type=checkbox]:checked") .length; if(checked > 0) { alert(checked + " CheckBoxe(s) are checked."); return true; } else { alert("Please select CheckBoxe(s)."); return false; } }); }); </script> </body> </html>