in my recaptcha google why submit don't work?
Asked Answered
B

1

1

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.

Blastogenesis answered 30/9, 2020 at 11:29 Comment(7)
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.Haematothermal
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 ?Blastogenesis
By googling a little bit :) Stop form refreshing page on submitHaematothermal
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.Blastogenesis
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?Strike
It seems, I have a similar problem. The form submits fine without ReCAPTCHA. As soon as I call "render" on the submit button, the form does not get submit anymore, and the render's callback parameter does not get called neither. BTW, I've read that another guy fixed this by changing submit button's ID to something other than submit . I see that you have the same case, so maybe the solution for v2 was to change submit button's ID, in your case.Vaughn
@JānisElmeris I have opted to recaptcha v3, it is easier to use and this solved my problem.Blastogenesis
B
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!

Blastogenesis answered 3/10, 2020 at 16:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.