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
Wesley Haines
4,934 PointsjQuery Email Validation Plugin Code Challenge 4 of 4
Not sure what I am doing wrong here...
"In the "success" function add the class of "valid" to the textarea that's had a the "keyup" event triggered."
<script>
var isValid = $('input').validEmail();
$('textarea').validEmail({
on:'keyup', success:function(){
$(this).addClass('.valid');
}, failure:function(){
}});
</script>
Wesley Haines
4,934 Pointssometimes its just the easiest fixes... thanks.
3 Answers
Jon Sultana
6,916 PointsFrom what I remember with this lesson the code was like this
function isValidEmail(email){
return email.indexOf("@") != -1;
}
$("#email").keyup(function(){
//check for a valid email
if(isValidEmail($(this).val()))
$(this).next().removeClass("error").addClass("valid");
else
$(this).next().removeClass("valid").addClass("error");
Let me know if this helps
});
Jon Sultana
6,916 PointsI might not be as far as you and this may not relate to what you are talking about
Wesley Haines
4,934 Pointsyea... it does not always work to copy the code from the video. I have tried it many times too.
Jon Sultana
6,916 Pointstry to google the question Treehouse gives you and it may bring up the answer for it. Im not a big fan of using the code pen quizes because of this.
Good luck!
Joshua Moore
8,013 PointsWhen you add a class you need to leave out the period before the word. Also, instead of using "this", I used "textarea", so I don't know if that would also be a problem.
ratandeepbansal
6,145 PointsIts better to use "this" because you only want to add the 'valid' class to the email textarea, for which you have checked using the 'vaildEmail' function.
Tom Mertz
15,254 PointsTom Mertz
15,254 PointsHave you tried just passing "valid" into addClass without the period?