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

Adam Soucie
PLUS
Adam Soucie
Courses Plus Student 8,710 Points

JQuery Plugins: Simple Email Validation Plugin Challenge 3 of 4

I'm getting an error that doesn't make sense. According to the code engine, after passing Task 2, my code breaks it in Task 3. Please help.

<script type="text/javascript">
    var isValid = $("input").validEmail();
    var isValid2 = $("textarea").validEmail(on:"keyup", success:function(){}, failure:function(){});
</script>

I've tried it both with and without assigning the value of the second validEmail() call to a variable, and get the same error. At this point, I don't know what I'm doing wrong.

4 Answers

J.T. Gralka
J.T. Gralka
20,126 Points

Adam,

Don't forget that the hash that you pass through as an argument to the validEmail() method, should be encapsulated in curly braces! You're passing through one argument to the method, not three separate ones.

The way you have it:

$("textarea").validEmail(on:"keyup", success:function(){}, failure:function(){});

Notice that your version of the code omits curly braces. If you rewatch the Simple Email Validation Plugin video again, you might notice that Andrew puts his on:, success:, and failure: arguments into an option hash surrounded by curly braces.

Let me know if that doesn't fix your issues, or if any of my explanation is unclear to you.

Cheers,

J.T.

Adam Soucie
PLUS
Adam Soucie
Courses Plus Student 8,710 Points

JT, that makes perfect sense. I completely missed the extra curly braces, both here and when I watched the original video. Thanks!

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

Glad J.T. chimed in!

Semi colons, single equals, missing curly braces and brackets are always a problem!

Some of most fun and effective times I've had developing is pair programming because you catch each others missing syntax and you can learn a lot too.

Regards Andrew

Thanks! Finally got this passed. The curly brackets are sneaky!