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();
}