jQuery provides special selectors for this:
$('input:checked').length
More specific:
var num = $('#myform input:checkbox:checked').length;
jQuery :checkbox, :checked . , :checkbox , [type=checkbox], :
var num = $('#myform input[type=checkbox]:checked').length;