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

benjamin perodeau
benjamin perodeau
7,469 Points

interest waning

Andrew's interactive website project: over it. No fun at all. It's like I'm learning a foreign language from a teacher who teaches me the words for numbers one through ten then asks me to perform linear algebra. Boo. Hisss.

function requiredValues(){
  var blanks = new Array();
  var $required = $(".required");
  $required.each(function(){
    blanks.push($(this).val() == "");
  });
    return blanks.indexOf(true) != -1;
}

This doesn't work. I can't find in the video what's wrong with mine or any crumbs that would help me find the accepted answer. Please help. Thanks, Ben

7 Answers

Chris Dziewa
Chris Dziewa
17,781 Points

This is correct for the third challenge:

function isValidEmail(email) {
  return email.indexOf('@') !== -1;
}

function requiredValues() {
  var inputs = [];
  $(".required").each(function() {
    inputs.push($(this).val());
  });
  return inputs;
}

function containsBlanks(){
  var blanks = new Array();
  var $required = $(".required");
  $required.each(function(){
    blanks.push($(this).val() == "");
  });
    return blanks.indexOf(true) != -1;
}
Chris Dziewa
Chris Dziewa
17,781 Points

Honestly I love Treehouse, but the jQuery stuff on here was not very good. It didn't explain why you were doing what you were doing. It was basically dictating exactly what we needed to write. The new jQuery course that is coming should hopefully be better but honestly, for the time being go to Code School and do the free try jQuery course. In three hours or less, you will get a good handle on jQuery. If it's in the budget, I'd recommend getting a membership there as well. The two complement each other very well. Code School is usually just for the more intermediate to advanced levels. Their JavaScript courses are also very good. At the very least, try the jquery course since it's free, you just have to sign up (no credit card). You'll probably love it. I actually had them reset it for me so I can redo the whole course. Hope this helps.

benjamin perodeau
benjamin perodeau
7,469 Points

Thanks bru. Checked into code school. They have some free courses that interest me. I'm gonna give the jQuery a shot...and maybe a couple more. I think for me it's an either/or proposition. I'm gonna move forward with whichever service is better.

Do you have access to the correct code for this code challenge item?

Chris Dziewa
Chris Dziewa
17,781 Points

Is this from the second of the challenges?

Chris Dziewa
Chris Dziewa
17,781 Points

If this is from the second challenge it should be this (note variable names can be different from mine):

function isValidEmail(email) {
  return email.indexOf('@') !== -1;
}

function requiredValues() {
  var inputs = [];
  $(".required").each(function() {
    inputs.push($(this).val());
  });
  return inputs;
}
Chris Dziewa
Chris Dziewa
17,781 Points

I believe this was for the third challenge. I think the only thing you did wrong was set the function name incorrectly. It should be function containsBlanks(). Hope this helped.

benjamin perodeau
benjamin perodeau
7,469 Points

It's the third challenge, second item. The torturebot insists that I name the function 'requiredValues' but all the other error messages are too generic to be of any use. Most every other thing I've tried has returned a msg of 'There is something wrong with your code...'

benjamin perodeau
benjamin perodeau
7,469 Points

Completed the Code School jQuery intro. It was very effective. Thanks for recommending. I think the code challenges were appropriately geared toward the content without simply duplicating the instructor's code. I also liked how the skills were presented sequentially through a consistent narrative.

Chris Dziewa
Chris Dziewa
17,781 Points

Yeah I really like them, the only thing is there are less courses on that site and some of them are difficult if you are just starting out with a language (i.e. Ruby on Rails). The forum is easier to navigate on Treehouse and has more activity and Treehouse has more content available . I do like having both subcriptions even though I held out on spending the money for a while. Treehouse is good for building a foundation as a beginner to intermediate level programming and I like that they also include Android programming and PHP which Code School doesn't offer. Code School caters toward the intermediate to advanced level programmer with the exception of a few courses. Glad you liked the course though!