With the help of answers I found here, I try to disable submit button and send an alert message when clicked on it until there\'s not at least 2 checkboxes checked.
What
You should change your code as
$('#frmCompare :checkbox').change(function(){ //update selected variable selected = $('#frmCompare :checkbox:checked').length if (selected >= 2) { $('#btnCompare').attr('enabled'); } });