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 Build an Interactive Website Form Validation and Manipulation Checking Values

jquery form validation and manipulation challenge 3/3

It doesn't work. why?

function containsBlanks(){

  var vals = [];

  $.each($('.required input'), function(){
    vals.push($(this).val());
  });

  return vals.indexOf('') != -1;
}

2 Answers

I think it's the inputs that have a class of required.

You're selecting input elements that are within an element with a class of "required".

Try $('.required')

Gareth Borcherds
Gareth Borcherds
9,372 Points

If you want to ensure that you are selecting inputs with the class required you can use something like $('input.required') which will allow jQuery to select the correct inputs with those required elements.