Support Forums

Netlify Default "Thank You page" not showing after adding reCaptcha React/Gatsby

The default Thank you message for my site was showing until I added the Recaptcha. Now I can receive the messages but the site just got reloaded and did not redirect to netlify thank you page after adding recaptcha.

The Site link.
https://eloquent-lamarr-932925.netlify.app/ (The form is at bottom, of home page, )

The Code

ref={e => recaptchaInstance = e}

const handleSubmit = (e) => {
if (isVerified) {
fetch("/", {
method: “POST”,
headers: { “Content-Type”: “application/x-www-form-urlencoded” },
body: encode({
“form-name”: “home”,
acceptsconsentcheckbox: acceptsConsentCheckbox,
}).catch((error) => alert(error));
name: “”,
phone: “”,
email: “”,
message: “”,

} else {

alert(“Please verify that you are a human!”);

You’re using JavaScript to submit the form. While I don’t see preventDefault() being called in the code above, I do believe you might be using it somewhere to prevent the submission without validating. In JS submissions, there won’t be any thank you page as the data is sent using Fetch. You’d have to redirect the users to a thank you page using JS.