0

So i have forms made from wpcf7 plugin in my site. Now i have added Google reCAPTCHA v3 to one of my form and when i try to submit my form it reloads with sitename.com/#wpcf7-f468-o1 and displays the wfcf7 success message. I do not have any console errors.

this is my callback script

 <script src="https://www.google.com/recaptcha/api.js" async defer></script>
 <script>
      function onSubmit(token) {
         document.getElementById("homepage-form").submit();
      }
 </script>

this is my submit button in cf7 plugin

 <button class="orange-btn border-0 mt-3 g-recaptcha" data-sitekey="xxxxxxxxx" data-callback='onSubmit' data-action='submit'>Send Message</button> 

How do i stop the reload and just show success like normal wpcf7 form that uses Ajax?

I have wp_head(), and wp_footer() in header.php and footer.php respectively.

I tried using default recaptcha integration in contact form7 plugin adding site keys and secret. using default cf7 form no custom function - here the same issue occurred and also form was getting submitted twice

2
  • It would appear that you've either disabled wpcf7_load_js or something similar. You can't trigger onsubmit like you are in cf7. If you're using g-recaptcha v3 why not use the integration provided by the cf7 plugin?
    – Howard E
    Commented May 5 at 10:28
  • I have mentioned above That i did try that however got the same issues. Also I have not disabled wpcf7_load_js, Commented May 8 at 6:29

0