What is CAPTCHA

A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown below, but current computer programs can't

What is reCAPTCHA

reCAPTCHA is a free CAPTCHA service that helps to digitize books, newspapers and old time radio shows. For more information see the reCAPTCHA website.

Here is a sample of a reCAPTCHA image on a website.

Steps

  1. Register your domain with the reCAPTCHA website.
  2. Download the Java library from here.
  3. Download the Div.java and ReCaptchaField.java.
  4. Add the following code into your click form.
Declaration
ReCaptchaField  reCaptchaField = new ReCaptchaField("captcha", 
                                                    YOUR_CAPTCHA_PUBLIC_KEY,
                                                    YOUR_CAPTCHA_PRIVATE_KEY, 
                                                    ReCaptchaField.THEME_CLEAN);
Add to form
Div reCaptchaHolder = new Div();
reCaptchaHolder.add(reCaptchaField);
form.add(reCaptchaHolder);
  • No labels

1 Comment

  1. Click 2.3.0 has made some changes. So I updated ReCaptchaField to make it work with 2.3.0

    Here is two things that I have done.

    1. Import lib from apache instead of sf

    2. onProcess method will only process field if it participated in the incoming request which in this case does not call the validate() method. So I override the onProcess method.

    ReCaptchaField.java for Click 2.3