• SJW

    (@whitsey)


    I want to use reCaptcha but the integration into Contact Form loads recaptcha on every page which results in a poor page speed result.

    Therefore, I have attempted to load the code manually as per the recaptcha site and ONLY on the contact page: https://developers.google.com/recaptcha/docs/v3

    I load the scripts in the header ONLY IF I am on the contact page = OK

    I add the attributes to the button through an action hook filter.

    However, when the onSubmit callback is called, it does not submit the form and does not produce any errors.

    Is there something in the way that contact form is submitted that renders this code unusable?

    
    <script>
       function onSubmit(token) {
         document.getElementByClassName("wpcf7-form").submit();
       }
     </script>
    
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter SJW

    (@whitsey)

    document.getElementsByClassName("wpcf7-form")[0].submit();

    This works but it bypasses the CF7 checks and submits the form without validating fields.

    How can I resume normal transmission after interception?

    kkow

    (@kkow)

    select the forms submit button and simulate a click with “.click()” instead of “.submit()”

    you will likely need to have a check to make sure you don’t get stuck in a loop of intersecting the form on click and then having the program click again.

    Thread Starter SJW

    (@whitsey)

    The onSubmit callback is attached to the button click so I did think about that but it wont work.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to manually intercept and submit form’ is closed to new replies.