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

Josef Coban
Josef Coban
7,260 Points

Stuck on validEmail plugin

Hey guys I'm stuck and have no clue how to get past the second task in this project: Challenge task 2 of 4 Open a new script tag and using the "validEmail" plugin, store in a variable "isValid" whether the email address in the text input is valid.

<!DOCTYPE html>
<html>
<head>
    <title>Plugin</title>
      <style type="text/css">
      .valid {
        color: green;
      }
      </style>
</head>
<body>
      <p>
          <input type="text" value="andrew@teamtreehouse">
      </p>
    <p>
        <textarea>andrew@teamtreehouse.com</textarea>
    </p>
<script type="text/javascript" src="jquery.js"></script>
<script type ="text/javascript" src="validEmail.js"></script>
<script>
$("input.email").validEmail({on:"input", success:_success_handler_, failure: _failure_handler_});
</script>
</body>
</html>

I figure I have to tweak the code in the plug in there but no matter what I try I can't figure it out, I keep getting a message saying the validEmail method wasn't called in input. Please help!

3 Answers

Josef Coban
Josef Coban
7,260 Points

doh, figured it out lol...var isValid = $("input").validEmail(); is the answer.

Josef Coban
Josef Coban
7,260 Points

doh, figured it out lol...var isValid = $("input").validEmail(); is the answer.

Kaitlyn Dryer
Kaitlyn Dryer
18,581 Points

Sure enough! This is exactly what I had except that I wasn't putting "input" in quotes. Not really sure how it works though! The process shown in the video was quite different.