Google Recaptcha enterprise version include multiple times on the same page in magento 1.9

309 Views Asked by At

I want to include google Recaptcha enterprise version multiple times on the same page.

I have 2 forms on the same page -

<form class="newsletter-form" id="newsletter-form-<?php echo $formId?>" action="<?php echo $this->getNewsletterUrl() ?>" method="post" onsubmit='
newsletterPreSubmit(this, "<?php echo $siteKey?>")'>
...
<button type="submit" class="g-recaptcha btn btn-primary waves-effect">anmelden</button>
</form>

I have same form twice on the same page. $formId will make id attribute in tag unique.

newsletterPreSubmit: function (element, siteKey) {
        event.preventDefault()
        grecaptcha.ready(function () {
            grecaptcha
                .execute(siteKey, { action: 'submit' })
                .then(function (token) {
                    var input = $j("<input>")
                        .attr("type", "hidden")
                        .attr("name", "g-recaptcha-response").val(token);
                    $j(element).append(input)
                    $j(element)[0].submit()
                })
        })
    }

In this case, I am unable to submit second form and in case of first form, score is always 0.1

Can somebody support me, how can I do it?

0

There are 0 best solutions below