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

HTML Build an Interactive Website jQuery Plugins Simple Email Validation Plugin

Samuel Rueby
Samuel Rueby
22,538 Points

Build an interactive website challenge 3 - confusing wording.

What is the wording of this challenge trying to say?

"On the next line select the "textarea" call "validEmail" and pass in the parameters of "on" set to "keyup", and "success" and "failure" set to empty anonymous functions."

Call validEmail on the textarea? Pass in the parameter of "on" what? What success and failure functions? You're not able to view the source of validEmail in the challenge.

3 Answers

Ron McCranie
Ron McCranie
7,837 Points

Don't worry about needing to see the contents of the validEmail.js plugin. You're just going to call the function from the file you're working with.

  1. Select the text area: $('textarea')
  2. Call valid Email: $('textarea'),validEmail();
  3. pass the parameters of "on" set to "keyup": on:'keyup'
  4. success and failure to empty anonymous functions: success:function(){ }, failure:function(){}

EXAMPLE OF EMPTY anonymous FUNCTION:

// anonymous means there is no name for the function
function() { /*--this part here is empty--*/ };

FINAL CODE:

    var isValid = $('input[type="text"]').validEmail();
   $('textarea').validEmail({  
    on:'keyup',
    success:function(){ },
    failure:function(){}
  });
Shawn Flanigan
PLUS
Shawn Flanigan
Courses Plus Student 15,815 Points

on, success, and failure are all parameters for the validEmail function in the plugin. When calling the validEmail function, you can optionally pass these parameters (and values for them) into the function as an object. Here's what that will end up looking like for this task:

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

Hope this helps!

Thomas Horner
Thomas Horner
11,185 Points
$('textarea').on('keyup', success: function(){
}, 
 failure: function(){
})