Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Sam Bell
Sam Bell
4,410 Points

Only submit form if all checkboxes are selected

Trying to find a solution to only submit form if ALL checkboxes have been selected. Here is my code so far. If all checkboxes are selected then change colour of form button.

checkboxCheck = function(event, target){

var beforeAppBtn = document.querySelector('.applicationForm form button');

if (target.checked == true){

    beforeAppBtn.classList.add('active');

  } else {

    beforeAppBtn.classList.remove('active');
  }

}

document.body.querySelector('.beforeYouBegin form'), '.input input', 'click', checkboxCheck);

1 Answer

Steven Parker
Steven Parker
229,657 Points

The syntax of that last line doesn't seem correct, is there something missing?

Also, it's hard to understand what this code does without also seeing the HTML and CSS components. To facilitate a complete analysis, always provide the complete code (formatted using Markdown) or make a snapshot of your workspace and post the link to it here.