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.

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.