var selected = []; // New array
$("#inputID input[type=checkbox]:checked").each(function () {
selected.push(this.value);
});
var values=[];
$('input[name="your-checkbox-name[]"]:checked').each(function () {
values[values.length] = (this.checked ? $(this).val() : "");
});
$('input:checkbox').prop('checked', true);
<form id="form1" action="/controller/action" method="post">
<input type="checkbox" name="box1" class="cBox" />
<input type="checkbox" name="box2" class="cBox" />
<input type="checkbox" name="box3" class="cBox" />
<input type="submit" value="Submit" />
</form>
<script>
$('#form1').submit(function() {
if ($('input:checkbox', this).length == $('input:checked', this).length ) {
// everything's fine...
} else {
alert('Please tick all checkboxes!');
return false;
}
});
</script>
$('.theClass:checkbox:checked')
//html
<input type="checkbox" onclick="CheckAll(this)" id="checkboxAll" title="Select All" />
//jquery
function CheckAll(elem) {
$('[name="checkbox"]').prop("checked", $(elem).prop('checked'));
}