0

I have used this code from google recaptcha, but the submit didn't work (after google captcha nothing happen), the form is not submitted, maybe because i have added my own action for the salesforce ?

    <html>
    <head>
    <script>
  var onSubmit = function(token) {
      console.log('success!');
    };

        var onloadCallback = function() {
          grecaptcha.render('submit', {
            'sitekey' : 'your_site_key',
            'callback' : onSubmit
          });
        };
    </script>
  </head>
  <body>
    <form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" thod="POST">
      <input id='submit' type="submit" value="Submit">
    </form>
    <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
        async defer>
    </script>

      </body>
</html>

i have also used google recaptcha v3,

my form is submitted but in server side i receive an empty array.

Mohamed Masmoudi
  • 423
  • 6
  • 20
  • 1
    I believe that 1. when you submit your form, it reloads the page. That's the default behaviour that needs to be prevented (event.preventDefault etc). Also 2. You wrote `thod` instead of `method.` – Jeremy Thille Sep 30 '20 at 12:54
  • Yes, i made a mistake writing method, i fix it but the form don't submit and reload the page, how can i fix that ? – Mohamed Masmoudi Sep 30 '20 at 16:42
  • By googling a little bit :) [Stop form refreshing page on submit](https://stackoverflow.com/questions/19454310/stop-form-refreshing-page-on-submit) – Jeremy Thille Sep 30 '20 at 17:39
  • This not the problem, my problem is that the form is not submitting at all, when click on submit button nothing happen, sometimes the google captcha appear that's all. – Mohamed Masmoudi Sep 30 '20 at 18:02
  • Hello @MohamedMasmoudi 2 questions: first in the `'sitekey' : 'your_site_key',` you used your recaptcha key right? second, do you get any errors in Console? – Mihail Minkov Oct 02 '20 at 15:36

1 Answers1

0

To resolve my issue, i have upgrade it to the reCaptcha v3, it was a lot easier to integrate to my html code. Thanks everyone!

Mohamed Masmoudi
  • 423
  • 6
  • 20