Trying to make some required fields in a checkbox with Jquery

Go To StackoverFlow.com

0

I an working in a fiddle (here). In this, I need to have some mandatory fields checked before I perform any calculations. There are 6 mandatory fields, so I am trying to check to see that all 6 required inputs (whose TRs have their own class) are checked. I use $('tr.mustPass').find('input.subFieldCheck:checked').length to check this, but it does not seem to work. Whether or not this is six, my if statement says that it is not and sends out an alert stating this.

What am I doing wrong?

Thank you for your help.

2013-04-14 18:10
by Starfyre


1

Your JavaScript had a missing comma, and bracket. Also, lowered the specificity on your CSS selector slightly:

$('#calculate').on('click', function(event) {
   console.log($('tr.mustPass').find('input:checked').length)
});

That will log the number of checked required checkboxes to the console. (Fiddle)

2013-04-14 18:16
by Michael Wright