How to do checkbox count marked when clicking on Submit?

Asked

Viewed 30 times

-2

How to implement checkbox count marked when user clicks on Ubmit, when at least two fields were marked in the code below:

<script>
// Limita a quantidade de cliques
$(".limited1<?php echo $i; ?><?php echo $i4; ?>").click(function() {
    var bol = $(".limited1<?php echo $i; ?><?php echo $i4; ?>:checkbox:checked").length >= 1;     
    $(".limited1<?php echo $i; ?><?php echo $i4; ?>:checkbox").not(":checked").attr("disabled",bol);
});
</script>

1 answer

0

To check how many checkboxes have been marked on the page you can use the following javascript function:

var array_checked = document.querySelectorAll('input[type="checkbox"]:checked')
var number_of_checked = array_checked.length

Browser other questions tagged

You are not signed in. Login or sign up in order to post.