Form submission failed: Error: There was an error running execute() on the reCAPTCHA script.
Error img
When I try to send an amp form with an amp-recaptcha, I get this error. I generated different keys, all have "Allow this key to work with AMP pages" enabled.
Do you have an idea what is the problem? Thx.
<form id="amp-recaptcha-input-form" method="POST" action-xhr="https://example.com/api/push" target="_top">
<fieldset>
<label>
<span>Search for</span>
<input type="search" name="term" required>
</label>
<input name="submit-button" type="submit" value="Search">
<amp-recaptcha-input layout="nodisplay" name="recaptcha_token"
data-sitekey="6LcovLIUAAAAAEfNnsbk69bEKH6LvBM2_2rAxmoj" data-action="recaptcha_example">
</amp-recaptcha-input>
</fieldset>
<div class="loading-message">
Loading...
</div>
<div submit-success>
<template type="amp-mustache">
<h1>You searched for: {{term}}</h1>
<div><b>Score:</b> {{score}}</div>
<div><b>Recaptcha token:</b> {{recaptcha_token}}</div>
<div><b>Action:</b> {{action}}</div>
</template>
</div>
<div submit-error>
<template type="amp-mustache">
<h1>Error! Please check the JS Console in your dev tools.</h1>
<p>{{message}}</p>
</template>
</div></form>
I too am implementing reCAPTCHA on my AMP pages. Firstly you need to use the AMP reCAPTCHA input component in the form (amp-recaptcha-input). After this you will need to verify the token generated for reCAPTCHA v3 the same way as for reCAPTCHA v2. That is, in the code behind using API request (post method) to https://www.google.com/recaptcha/api/siteverify - by sending the secret key, token and user IP address (optional). You'll get a JSON response that you can parse and verify before actually submitting the form data to your database or email code.
Refer:
I had the same problem. There was no error with the code. Google reCAPCHA consol permissions caused the problem.
Go to the Google reCAPCHA Admin site (https://www.google.com/recaptcha/admin/) Settings tab! Set the Domains, add Your site width www And check the „Allow this key to work with AMP pages” box
Like this:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With