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 trialMarcelo 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?