I am trying to use Google Invisible reCAPTCHA, but it is sending empty the g-recaptcha-response
POST parameter when i have multiple forms in the same page. Here is my code:
Google JS
<script src="//google.com/recaptcha/api.js?hl=pt-BR&onload=captchaCallback&render=explicit" async defer></script>
Form 1
<form action="/site/Contact/send" id="form1">
<input type="text" name="nome" required>
<div class="g-recaptcha"
data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxx"
data-callback="form1Callback"
data-size="invisible">
</div>
<button type="submit">Send</button>
</form>
Form 2
<form action="/site/Contact/send" id="form2">
<input type="text" name="nome" required>
<div class="g-recaptcha"
data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxx"
data-callback="form2Callback"
data-size="invisible">
</div>
<button type="submit">Send</button>
</form>
My JS (Based on this answer]
$(document).ready(function() {
window.captchaCallback = function(){
$('.g-recaptcha').each(function(index, el) {
var attributes = {
'sitekey' : $(el).data('sitekey'),
'size' : $(el).data('size'),
'callback' : $(el).data('callback')
};
grecaptcha.render(el, attributes);
});
};
window.form1Callback = function(){
$('#form1').submit();
};
window.form2Callback = function(){
$('#form2').submit();
};
});
When i submit one of these forms the g-recaptcha-response
parameter is sent empty, as below.
Can someone help me to put it to work, please?