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

Simple Email Validation Code Challenge - Stuck

Hi All,

I'm stuck on the second step of the Simple Email Validation Plugin code challenge in the jQuery Plugins module by Andrew.

The challenge says "Open a new script tag and using the "validEmail" plugin, store in a variable "isValid" whether the email address in the text input is valid."

Using the video and the readme on the GitHub page for Andrew's plugin, I've written:

<script>
  var isValid = $(input).validEmail();
</script>

I think this should work as it should evaluate the contents of the <input> and return a boolean as per the readme and the video. However, I'm getting the error "The validEmail method wasn't called on input". I've tried a few variations, but can't get anything to work. Am I missing something, or is it a bug with the code challenge?

Many thanks,

Dan

P.S. Sorry if this has been asked before, but there doesn't seem to be a search on the forum...

6 Answers

James Lister
James Lister
6,569 Points

I've put in the same code as far as I can see but it won't work? <script> var isValid = $("input").validEmail(); </script>

What is going on here?

Nevermind - schoolboy error! :-)

I forgot the quotes.

$("input")
James Lister
James Lister
6,569 Points

Oh my gosh, that sparked something in my brain... in task 1 I had <script type="text" src ="validEmail.js"></script> which passed... but then in task 2 I added /javascript after "text" and it worked! Thanks again!

I have the same problem... I don't know whats going on

<script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="validEmail.js"> var isValid = $('input').validEmail(); </script>

Andrew Chalkley
Andrew Chalkley
Treehouse Guest Teacher

You're almost there.

If the src attribute is defined you cannot put code inside it. If you create another script tag and put the code in you'll be fine:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="validEmail.js"> </script>
<script type="text/javascript">var isValid = $('input').validEmail();</script>

Thanks Andrew, I hope I become as good as you are in javascript!!