Talk galley blz? I need a help I implemented 3 recaptchas on the same page.
<form id='form1'><div class="g-recaptcha" id="Login" data-sitekey="minhakey"></div></form>
<form id='form2'><div class="g-recaptcha" id="reset" data-sitekey="minhakey"></div></form>
<form id='form3'><div class="g-recaptcha" id="email" data-sitekey="minhakey"></div></form>
In my js file I put the following code.
var CaptchaCallback = function(){
$('.g-recaptcha').each(function(index, el) {
grecaptcha.render(el, {'sitekey' : 'minhakey'});
});
};
and finally in the footer
<script src="https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit"asyncdefer>
That'sokay.itgeneratesthepagewiththe3formsandthe3reCAPTCHAStheproblemisinvalidationwhenIusegrecaptcha.getResponse()
itonlyworksforthefirstrecaptcha.fortheother2doesnotworkSoIfoundongooglethatifIuzarthiswayitwouldworkgrecaptcha.getResponse(elementId);
ThenIusedvarresponse=grecaptcha.getResponse(reset);
Sowhendoingthisinsteadofrecordingitinthevariableresponseitmakesarequestinmypagewiththeresponseandmypageupdateswiththeurlofmysite+theresponse
link
Has anyone ever faced this problem or does anyone know how to solve it? thank you in advance;
I did as you said:
var reLogin;
var reLost;
var reRegister;
var onloadCallback = function() {
var reLogin = grecaptcha.render($('#reLogin')[0], {'sitekey' : '6LcZ-wsUAAAAAOkcUWs5OiVIQW6Td2aIYPf8aMxe'});
var reLost = grecaptcha.render($('#reLost')[0], {'sitekey' : '6LcZ-wsUAAAAAOkcUWs5OiVIQW6Td2aIYPf8aMxe'});
var reRegister = grecaptcha.render($('#reRegister')[0], {'sitekey' : '6LcZ-wsUAAAAAOkcUWs5OiVIQW6Td2aIYPf8aMxe'});
};
and my onclick validation
alert(grecaptcha.getResponse(reLost));
Only the alert comes in.