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.

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,836 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,803 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(){
})