Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I skip reCaptcha test and just submit form I've got an error that I've wrong captcha answer. That's ok, but reCaptcha dispalayed just once - before form submit. So, user can't submit form anymore while he can't see reCaptcha field. Can you fix this?
I've tested both 2.x alpha and dev versions and they affected with this bug. Btw, I think this bug exist only with Webform module.
Comments
Comment #1
cslevy CreditAttribution: cslevy commentedThe problem is with the ajax, but i found a workaround for this.
Comment #2
Liam Morland@Xrobak: Please provide steps to reproduce this problem.
@cslevy: Please provide your changes as a patch.
Comment #3
mariusdiacu CreditAttribution: mariusdiacu commentedI also have this problem with a node that has recaptcha attached. I added #ajax on submit button (form is in a reveal modal) so each time the user hits submit an there are validation errors, the recaptcha is not rebuild. Being inactive, user cannot save the node.
I tried the code above for node, with some changes. I don't know for sure if this is the right way. What I did is to check if the elements with data-sitekey attribute are empty or not. If so, I reset the captcha.
I didn't add a patch, I am not sure this is the right approach...
Comment #4
cslevy CreditAttribution: cslevy commented@Liam Morland
Actually these aren't changes in any module. Simply add this behaviour in your own javascript (from theme or custom module)
Comment #5
Liam MorlandShould this JavaScript be included as part of the Drupal recaptcha module?
Because I do not have steps to reproduce the problem, I do not understand clearly what is going wrong.
Comment #6
mariusdiacu CreditAttribution: mariusdiacu commented@Liam Morland
The problem is that if you add ajax submit on the forms were you have captcha, the captcha will not work after first ajax submit (e.g. you submit, but you forget to fill a required field. The form is rebuild with ajax, but the recaptcha will not appear anymore. Only after refresh)
Comment #7
Liam MorlandI haven't done much with ajax forms, so I am not very familiar with implementing them in Drupal. Does this mean that the Drupal recaptcha module has a bug or is it that the documentation should inform those who create such forms to add JS like in the above comments?
Comment #8
keha3912 CreditAttribution: keha3912 commentedI'm confirm bug with Webform module
Comment #9
Massimo86 CreditAttribution: Massimo86 commentedOn my websites I use reCaptcha alot, so I'm interested in testing of this module
I've tried reCaptcha + Webform + Webform Ajax modules and for me it is impossible to repeat this issue. Do you use "Webform Ajax" module to get Ajax functionality for Webform?
While unsuccessful form submission (missed required field), sometimes you can fill out form and successfully submit reCaptcha, but forget to fill required field or use wrong format. When "Missed required field" message is shown and usually reCaptcha field will disappear, but when required field becomes filled and form is resubmitted, submission becomes successful even without showing and submitting reCaptcha.
Please give detailed steps, so issue can be repeated.
Comment #10
Liam Morland@keha3912: If the bug is in Webform, then this issue needs to be moved to the Webform queue. What happens of you use the math CAPTCHA? If Math CAPTCHA works properly, then the bug is probably in reCAPTCHA. Does it work properly with reCAPTCHA 7.x-1.x?
Comment #11
hass CreditAttribution: hass commentedComment #12
hass CreditAttribution: hass commentedClosing because of inactivity.
Comment #13
pobster CreditAttribution: pobster as a volunteer commentedIt's not a bug in webform and it is consistently reproducible - the reason for it is because recaptcha works via populating a div with an iframe via an onload. When you're using webform_ajax you get the div back, but there's no onload call - hence the need to re-render the captcha box. I fail to see how this is the fault of webform_ajax though?
Comment #14
hass CreditAttribution: hass commentedSounds like #2493183: Ajax support / Use behaviors
Comment #15
hass CreditAttribution: hass commentedComment #16
pobster CreditAttribution: pobster as a volunteer commentedYes absolutely, that looks to be the exact same issue. Thank you.
Pobster
Comment #17
arm75 CreditAttribution: arm75 commentedI know this is old, but if anyone needs this. I can confirm the javascript in #3 fixes the issue. I tried to add it to the Custom Javascript in the Webform, and it didn't work. But when I load the Javascript through the libraries.yml file, it fixes the error.
Comment #18
Froozeify CreditAttribution: Froozeify commentedFix from #3 also works for me