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

Looking for javascript-based CAPTCHA code

Hey guys,

So I've been asked to add a CAPTCHA to an existing form on a website. Apparently it needs to be javascript-based and coded on the front-end due to the way the client's site is set up.

Does anyone know a good one to use.

She doesn't want to use Google's reCAPTCHA and I've already tried this one but it didn't work: http://www.tothemoon.com/2013/01/simple-javascript-captcha-you-can-add-to-any-form/

Thanks!

3 Answers

You know, the best kind of CAPTCHA I've implemented is one that's invisible to users, called a Honeypot:

http://www.sitepoint.com/honeypot-captcha/

Several years ago I started using the popular Securimage CAPTCHA which worked reasonably well at the time, however:

  1. It was really annoying to users
  2. To make it mildly accessible you had to disable most of the techniques for fooling computers
  3. It was complicated to install initially

Fairly recently I learned that the very jarring user-input CAPTCHA's were becoming a bit tired and old-hat, and that the Honeypot was a fairly reasonable, no-nonsense approach, and I've had tremendous success implementing these in sites. The great thing is that they're easy to implement, and you don't have to rely on someone else's popular (and therefore easily hackable) code - and with some JS knowhow you can improve on the concept by building forms with JS, adding server side session challenges and more. So long as the web bot isn't rendering the page and using that as its mechanism for filling out forms, you're save - and most malicious bots go for the direct approach by reading the raw HTML.

Good luck!

Did you by chance keep the honeypot name? :smile:

I just took inspiration from the sweet sounding source, it's still a CAPTCHA, just a different form ;)

I've never really been satisfied with captchas, so I'm just going to recommend one open source project which looks pretty decent.

You can do something like this (very) simple HTML-only captcha, but ask a question harder for a computer to parse.

http://codepen.io/jamesbarnett/pen/Ixyin