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

jQuery 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>

Have you tried just passing "valid" into addClass without the period?

sometimes its just the easiest fixes... thanks.

3 Answers

From 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

});

I might not be as far as you and this may not relate to what you are talking about

yea... it does not always work to copy the code from the video. I have tried it many times too.

try 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!

When 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.

Its 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.