2

I've got recaptcha working in it's fundamental form - requiring a captcha code and displaying a basic error when it's wrong. But I want to make it more usable, and I'd really appreciate your help.

Is there any way to ajaxically send a test/request to see if the captcha code is correct, and if it's not, pre-emptively prompt the user for another attempt?

Failing that possibility - is there any way to ensure that all the fields keep their values if I were to php redirect the user back to the form page?

Thanks!

Matrym
  • 16,643
  • 33
  • 95
  • 140
  • Possible duplicate of [How to check in js that user has checked the checkbox in Google recaptcha?](http://stackoverflow.com/questions/28674946/how-to-check-in-js-that-user-has-checked-the-checkbox-in-google-recaptcha) – Huseyin Yagli May 06 '17 at 09:41

1 Answers1

2

reCAPTCHA has an AJAX API as described here.

You need to include the script in your page:

<script type="text/javascript" src="http://api.recaptcha.net/js/recaptcha_ajax.js"></script>

And then define a callback to fire when it gets the response:

Recaptcha.create("6LdIEwAA......",
  "recaptcha_div", {
  theme: "red",
  callback: Recaptcha.focus_response_field
});

There's a demo of it working here.

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
  • Unfortunately, both of your links are returning error 404 not found. Good thing you provided the actual content in your answer, as it retains value despite the broken links! – Ellie Kesselman Oct 18 '11 at 14:56