Hello,
when I activate Google reCAPTCHA and use the data-callback function it is not called.
Google explains this:
So in my opinion when I add this accordingly to my theme this function should be called before submitting the form and the form should not be auto-submitted, is that correct?
I also already tested to add it to the form as below:
{%- form 'create_customer', novalidate: 'novalidate', data-callback:'alterForm' -%}
But neither worked and Form is submitted all the time without calling that function. I need my own validation as well after or before reCAPTCHA did their verification. How can I do this with recaptcha activated?
-
Verify reCAPTCHA setup: Double-check that you have correctly integrated Google reCAPTCHA into your Shopify theme. Ensure that you have added the necessary reCAPTCHA script and site key to your theme files, typically in the form or button element.
-
Check for conflicting code or errors: Review your theme’s JavaScript files or any custom scripts you’ve added to ensure there are no conflicts or errors that may prevent the data-callback function from being executed.
-
Test the data-callback function: Test the data-callback function separately by adding a simple console.log statement or alert to verify if it gets triggered. For example:
Make sure the function is defined and accessible within the scope of your theme’s JavaScript.
- Investigate form submission code: If the form is still being submitted automatically despite having the data-callback function in place, there might be other JavaScript code or event listeners overriding the default behavior. Review the code that handles form submission, especially if you have custom form submission logic or other form-related scripts in your theme.
I did not integrate reCAPTCHA. I use the native Shopify Shopify Feature under Online Store → Preferences:
My theme is Dawn. When I deactivate the reCAPTCHA in Shopify Settings my code works very fine as expected. But when enhanced with the data-callback from reCAPTCHA it is not called as mentioned.