0
Speak blz guys ? I need a help implemented on the same page 3 recaptchas.
<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>
dai in my file js put the following Cod.
var CaptchaCallback = function(){
$('.g-recaptcha').each(function(index, el) {
grecaptcha.render(el, {'sitekey' : 'minhakey'});
});
};
and finally at the bottom
<script src="https://www.google.com/recaptcha/api.js?onload=CaptchaCallback&render=explicit" async defer>
So far so good.
it generates the page with the 3 Forms and the 3 reCAPTCHAS
the problem is in the validation
when using the grecaptcha.getResponse()
it only works for the first recaptcha. for the other 2 does not work
then I googled that if I did it would work
grecaptcha.getResponse(elementId);
so I used var response = grecaptcha.getResponse(reset);
so that by doing this instead of it recording in the Answer variable it makes a request on my page with Answer and my page updates with the url of my site + Answer
Please, has anyone ever faced this problem or does anyone know how to solve it? thank you so much;
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 validation on onclick
alert(grecaptcha.getResponse(reLost));
only that the Alert comes Vasio.
I’ll update you from a look please.
– Jasar Orion
You have to declare the
var reLogin
,var reLost
only outside the function, when declaring again inside the function, the JS creates another variable with the same name, but with scope only inside it.– Michelle Akemi
still didn’t work I took out the onloadcallback function and nothing :*(
– Jasar Orion
I think I’ll do it differently instead of keeping all forms hidden in the page I’ll do it by ajax.
– Jasar Orion
Leaves recaptcha out of the login/Lost/Register bid. Creates one and shows it regardless of what the user chooses.
– Michelle Akemi
ok I’ll try really thank you.
– Jasar Orion