Code stack you are integrating Builder with e.g. NextJS
**description
What I need is to include Google reCAPTCHA in the contact us form on our website. I was able to achieve this by creating a custom component. Now, I am trying to validate the CAPTCHA on form submission. For that, I implemented the validateRecaptcha method and passed it to the context through BuilderComponent. However, I am struggling to fetch the CAPTCHA response token from the Builder visual editor to pass to the validateRecaptcha method. I can see the value as a form field in the email that contains the form submission. What I need to do is capture the g-recaptcha-response in the custom code on submit button click and pass it to the validateRecaptcha method, which is available in my code base. I tried to bind it via event.target.value on reCAPTCHA submit/click, but the value is empty.
I was able to save the response in local storage and use it in the code base. Now my issue is how to avoid sending the g-recaptcha-response field in the email. Any idea on this?
To avoid sending the g-recaptcha-response field in your email, you need to ensure that this field is not included when you handle the form data on the client-side before sending it to your backend or email service.
Here’s how you can do this:
Step-by-Step Guide to Exclude g-recaptcha-response Field
Handle Form Submission:
Capture the form submission event.
Manipulate the form data to exclude the g-recaptcha-response field.
Send the modified form data to your backend or email service.
Step 1: Capturing Form Data and Excluding g-recaptcha-response
First, ensure you have set up your component for form submission and have integrated reCAPTCHA correctly.
Step 2: Handling reCAPTCHA
Make sure to handle reCAPTCHA correctly by adding it to your form and ensuring the token is properly set.
Summary:
Handle Form Submission: Capture form submission and prevent default behavior.
Exclude Field Before Sending: Create a clean form data object excluding the g-recaptcha-response field and send this object to your backend.
Recaptcha Token Handling: Ensure the reCAPTCHA token is handled correctly and used only where necessary (validation), but excluded from the email content sent.
By following these steps, you can ensure that the g-recaptcha-response field is used for verification purposes but not included in the email content sent from your application.
Hi @anon43891756 Thanks for your response. Yes, I have already fixed the issue by providing a custom code for form submission. I’ve posted it here in hopes that it can help someone with a similar issue.