-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AJAX forms do not work anymore with captcha #512
Comments
Same issue here. |
we'll take a look at this... |
This is due to the captcha integration bypassing our own event handlers by submitting the form. As a workaround, you can override the form's submit function. For instance, adapting the documentation: const form = document.querySelector('#ajax-test-form');
form.submit = function() {
const result = document.querySelector('#form-result');
const action = form.getAttribute('action');
const method = form.getAttribute('method');
fetch(action, {
method: method,
body: new FormData(form)
})
.then(function(response) {
if (response.ok) {
return response.text();
} else {
return response.json();
}
})
.then(function(output) {
if (result) {
result.innerHTML = output;
}
})
.catch(function(error) {
if (result) {
result.innerHTML = 'Error: ' + error;
}
throw new Error(error);
});
}
|
@dledanseur your code is the same as the one from the documentation, except the missing |
Not exactly the same, the key point here is to override the form's submit function with |
Any news about this. We're getting loads of spam because we needed to disable the captcha... |
More than a year has passed since the last answer... Spam is a real problem. Any news? |
Hi,
AJAX forms (as described in the documentation) do not work anymore when the form contains a
type: captcha
field.Ajax and captcha work fine wight grav-plugin-form v3.0.8, but fails from at least v4.0.0.
The text was updated successfully, but these errors were encountered: