reCAPTCHA integration

Hi,

reCAPTCHA integration has already been discussed here, but I would like to open another topic to understand if there are news.

Me and my team are trying to integrate reCAPTCHA to our landing page, using custom JavaScript, so for example we define following code.

<script src = "https://www.google.com/recaptcha/api.js" async defer> </script>

<script>
  document.addEventListener ("DOMContentLoaded", function () {
    var formElement = document.querySelector ("form");

    formElement.setAttribute ("onSubmit", "return onFormSubmit ();");
    formElement.innerHTML + = '<div id = "recaptcha" class = "g-recaptcha" data-sitekey = "{KEY}" data-callback = "onCaptchaCompleted" data-size = "invisible"> </div>';
  });

  function onCaptchaCompleted (token) {
    console.info ("onCaptchaCompleted:" + token);
    // DO SOMETHING AND THEN SUBMIT FORM
  }

  function onFormSubmit () {
    event.preventDefault ();
    grecaptcha.execute ();
    return false;
  }
</script>

The onFormSubmit function is called, but the submit event is not stopped, we tried different approaches, but none worked.

We would like to intercept the reCAPTHCA token and send it to Unbounce inserting it in a form field, this because we have a WebHook that can validate the request, but we didn’t find a way to stop the event for generate the reCAPTCHA token.

Do you have any suggestions?

Thanks,
Giuseppe