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

Could Someone Please Give Me a Hand With This Error: " Uncaught TypeError: undefined is not a function"

Hey guys,

So I'm building a form that features the form/email validation that Andrew Chalkley built in a early Treehouse video for the "Smells Like Bakin'" project. I've been able to implement it fine with other projects but for the site I'm currently building I keep getting the error: " Uncaught TypeError: undefined is not a function"

Here's the code block that seems to be throwing this error:

$("#email").validEmail({on:"keyup", success:function(){
    console.log('Code now works!');
    $(this).next().removeClass("error").addClass("valid");
}, failure:function() {
    $(this).next().removeClass("valid").addClass("error");
}});

Any advice on how I can get this working would be greatly appreciated!

Cheers

Stu :)

1 Answer

Erik Krieg
Erik Krieg
43,038 Points

I do not believe that validEmail() is a method of jQuery's, so, unless you have created a jQuery plugin for it, it is not going to work. Alternatively, the problem could be that you forgot to add jQuery to the page or have a typo in the script tag, but I am thinking my first suggestion is your problem.