Score:0

reCaptcha on webform does not present challenge if user skips it accidentally first time

ca flag

So here is the flow.

  1. user fills webform
  2. misses to respond to reCaptcha and hits submit
  3. The error appears to attend to reCaptcha BUT - there is no reCaptcha challenge presented again while the data user provided is saved.
  4. User is left wondering how to resubmit Captcha.
  5. Refresh the page is an option, but that removes the data that was saved on original user interaction and user will have to fill all elements again.

Form does use ajax, and I have tried persistence to present challenge always. I also tried using the grecaptcha.reset(); in javascript but that on its own did not work.

Any suggestions.

Atam Dhillon avatar
ca flag
I found a solution at - https://www.drupal.org/project/recaptcha/issues/2420079 The solution requires to paste the below javascript code to your pages. And Yes it worked but is this the best and only way possible?
Atam Dhillon avatar
ca flag
Code as per above comment - Drupal.behaviors.recapcha_ajax_behaviour = { attach: function(context, settings) { if (typeof grecaptcha != "undefined") { var captchas = document.getElementsByClassName('g-recaptcha'); for (var i = 0; i < captchas.length; i++) { var site_key = captchas[i].getAttribute('data-sitekey'); if (!$(captchas[i]).html()) { grecaptcha.render(captchas[i], { 'sitekey' : site_key}); } } } } }
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.