Ask for reCAPTCHA before sending

Hi,

I created a form that lets visitors send a message to a property owner, but the reCAPTCHA thing doesn’t work in my code.
I have disabled the reCAPTCHA in my code below because it’s not working. The sending without the reCAPTCHA works, it’s just that I want that reCAPTCHA for security.
Thanks for any help!

export function inquiry_click(event) {
 //Add your code for this event here: 
 let toInsert = {
 //Gets the values from the form and the image ID 
 "name": $w('#messageName').value,
 "lastName": $w('#messageLast').value,
 "email": $w('#messageEmail').value,
 "phone": $w('#messagePhone').value,
 "date": $w('#messageDate').value,
 "place": $w('#messageSpace').value,
 "message": $w('#messageBox').value,
 //"captcha": $w('#captcha1').token
  };
 
 
  wixData.insert("Messages", toInsert) //inserts the data into a collection
    .then((results) => {
 let item = results; 
 //resets the form
      $w('#messageName').value = '';
      $w('#messageLast').value = ''; 
      $w('#messageEmail').value = ''; 
      $w('#messagePhone').value = ''; 
      $w('#messageDate').type = '';
      $w('#messageBox').value = '';
 //$w('#captcha1').reset();
    })
    .catch((err) => {
 let errorMsg = err;
    });
}

Hey @nelsonmueller ,

To use reCAPTCHA to protect form submission, you need to send the generated captcha token for authorization in the backend of your site, check whether authorization is successful, and then perform the form submission. You reset the reCAPTCHA element following a submission or an error.

You can follow the instructions here: https://support.wix.com/en/article/corvid-tutorial-using-recaptcha-to-protect-data-submission

Note that if you use a Wix Form and not a custom form created with Corvid, you can protect your form with reCAPTCHA without adding any code: https://support.wix.com/en/article/protecting-your-form-from-spam-with-a-captcha-field

HTH,
Tova

Hi Tova,

Thank you for the reply.
I actually want to use the Wix form, but the thing is that it has to send the inquiry form to the email of the property owner. Is that possible using Wix form?

All I know is that it sends to me, but correct me if I am wrong. That’s why I created the custom form. The way I did right now is that it sends it to a page in the owner’s member area, but it is just showing on a repeater, which is okay. But no notification to the owner if a new message comes in, that’s the negative part of it.

Hi @nelsonmueller ,
No, it is not possible to send a Wix Form to the property owner. For that you do need Corvid. So if you would like to add reCAPTCHA to your Corvid form, you’ll need to follow the instruction in the posted tutorial.

If you would like to notify property owners when a form is submitted, you could use triggered emails .

All the best,
Tova

@talyaro
Hi Tova,

Thank you for finding time to answer me.

I understand. In this case I will look at that then.
Thanks for the help!

Sure, no problem. Good luck!