function onSubmit()
{
var fields = $("input[name='list']").serializeArray();
if (fields.length === 0)
{
alert('nothing selected');
// cancel submit
return false;
}
else
{
alert(fields.length + " items selected");
}
}
// register event on form, not submit button
$('#subscribeForm').submit(onSubmit)
//**************************************************
// HTML
<form method="POST" id="subscribeForm">
<fieldset id="cbgroup">
<div><input name="list" id="list0" type="checkbox" value="newsletter0" >zero</div>
<div><input name="list" id="list1" type="checkbox" value="newsletter1" >one</div>
<div><input name="list" id="list2" type="checkbox" value="newsletter2" >two</div>
</fieldset>
<input name="submit" type="submit" value="submit">
</form>
//This are the list of checkbox(2 selected, 2 unselected)
<input name="numchec" type="checkbox" value="1" checked/>
<input name="numchec" type="checkbox" value="2" />
<input name="numchec" type="checkbox" value="3" checked/>
<input name="numchec" type="checkbox" value="4" />
//Jquery Code
$(document).ready(function(){
var data=$('input[name=numchec]:checked').map(function(err, el) {
return $(el).val();
}).get();
alert(data)
});