1

As described in the title, I have the problem that I have two forms on one page. Is it possible to use a single captcha for both forms? And what about html5 form validation? I tried using the grecaptcha functions, but it didnt work. It never reaches the formSubmit() function.

I have this div in each of the forms:

 <div class="g-recaptcha"
        data-sitekey="6LeR9zEUAAAAACWWgcVtTs6JFvE0d9c2UNheIrtn"
        data-size="invisible"
        data-callback="formSubmit">
 </div>

The code to prevent the default of the submit button:

$('###sFormId#').submit(function(event) {
    if (!grecaptcha.getResponse()) {
    event.preventDefault();
    grecaptcha.execute();
    grecaptcha.reset(); 
   } else {
        console.log('form submitted');
   }
});

The function to submit:

function formSubmit(response) {
    console.log('submit function');
    document.getElementById("#sFormId#").submit();
}
  • 1
    Dupe of https://stackoverflow.com/questions/50481891/two-forms-on-a-single-page-with-capcha-html5-form-validation-is-not-working-any ? – Jules May 24 '18 at 17:41

0 Answers0