You are on page 1of 1

<!

DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("input[type=checkbox][name=checklimit]").click(function(){
var num = $("input[type=checkbox][name=checklimit]:checked").length;
if(num >= 2){
$("input[type=checkbox]
[name=checklimit]").not(":checked").attr("disabled",true);
}else{
$("input[type=checkbox]
[name=checklimit]").not(":checked").attr("disabled",false);
}
});
});
</script>
</head>
<body>
<input type="checkbox" name="checklimit">1<br>
<input type="checkbox" name="checklimit">2<br>
<input type="checkbox" name="checklimit">3<br>
<input type="checkbox" name="checklimit">4<br>
<input type="checkbox" name="checklimit">5<br>
</body>
</html>

You might also like