Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Marcelo Cortez
7,142 PointsHelp - Build an Interactive Website > jQuery Plugins > Simple Email Validation Plugin (4/4)
Hey guys, I'm stuck at code challenge "Simple Email Validation Plugin" 4/4
The error msg displayed when I ask to 'check my work': "Bummer! null"
Challenge: "In the "success" function add the class of "valid" to the textarea that's had a the "keyup" event triggered"
This is what I'm trying:
var isValid = $("input").validEmail();
$("textarea").validEmail({on:"keyup", success:function(){
$this.next().removeClass("error").addClass("valid");}, failure:function(){
$this.next().removeClass("valid").addClass("error");}
});
requiredFilledIn();
Any help is welcome ^^
5 Answers

Marcelo Cortez
7,142 PointsHi Andrew,
I tried and a new msg appeared: "Bummer! Try selecting 'this' in the success method and using the 'addClass' method"
So I tried some stuff and ended up with this:
var isValid = $("input").validEmail();
$("textarea").validEmail({on:"keyup", success:function(){
$(this).addClass("valid");}, failure:function(){
$(this).next().removeClass("valid").addClass("error");}
});
requiredFilledIn();
That worked ^^
Thnx for the help!

Paul Dunahoo
5,390 PointsIt could be just me, but are addClass("valid"); and addClass("error"); not supposed to have the closing brackets at the end?

Marcelo Cortez
7,142 PointsThe curly? They have...
"success:function(){ $this.next().removeClass("error").addClass("valid");}"
"failure:function(){ $this.next().removeClass("valid").addClass("error");}"

Andrew Chalkley
Treehouse Guest Teacher$this
should be $(this)
.
Cliff Garibay
7,023 PointsCliff Garibay
7,023 PointsI'm not sure how the .next() is supposed to be used. In the video lesson we use it apply the .addClass() and .removeClass() methods, but here you were able to pass the quiz by ommitting the .next() method?