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

Andrew Schumacher
Andrew Schumacher
17,487 Points

Simple Email Validation Plugin

What's the problem with my code? <script type="text/javascript">

var isValid = $("input").validEmail();

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

</script>

2 Answers

Tom Mertz
Tom Mertz
15,254 Points

Haha, yeah I got stuck at this part for so long.

I believe the validEmail method takes it's arguments as an array. See if that works.

Andrew Schumacher
Andrew Schumacher
17,487 Points

I'm not sure exactly what you mean by that. What would the syntax look like?

Tom Mertz
Tom Mertz
15,254 Points

Right now you are passing 3 arguments separately to validEmail separated by a comma:

validEmail(arg1, arg2, arg3);

But what you want is for those 3 arguments to be in an array

{arg1, arg2, arg3}

which would make the final code look like this:

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

Hope this helps.