How can we use several google recaptchas in the same page?












0















When i put



<script>
var renderCaptchas = function() {
grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});
};

var onloadCaptchaCallback = function () {
Array.prototype.forEach.call(document.querySelectorAll('.g-recaptcha'),
renderCaptchas);
};
</script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCaptchaCallback&render=explicit" async defer></script>


I have this error :




reCAPTCHA couldn't find user-provided function: onloadCaptchaCallback




The function is yet well defined ...
If i remove



grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});


Then it finds the callback ...
I use the Google ReCaptcha v2, with the checkbox "mode".










share|improve this question























  • There is multiple responses of similar question here : stackoverflow.com/questions/1241947/…

    – Shim-Sao
    Nov 24 '18 at 11:05













  • If you use JQuery, you should add : $(document).ready(function() { ... });

    – Shim-Sao
    Nov 24 '18 at 11:09











  • If you use prototype : document.observe("dom:ready", function() { ... });

    – Shim-Sao
    Nov 24 '18 at 11:15











  • I have already tested the DOMContentLoaded event with no success. The link provided suggests to use javascript and explicit rendering ...and it is what i am doing here.

    – mysthiq
    Nov 24 '18 at 11:21


















0















When i put



<script>
var renderCaptchas = function() {
grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});
};

var onloadCaptchaCallback = function () {
Array.prototype.forEach.call(document.querySelectorAll('.g-recaptcha'),
renderCaptchas);
};
</script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCaptchaCallback&render=explicit" async defer></script>


I have this error :




reCAPTCHA couldn't find user-provided function: onloadCaptchaCallback




The function is yet well defined ...
If i remove



grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});


Then it finds the callback ...
I use the Google ReCaptcha v2, with the checkbox "mode".










share|improve this question























  • There is multiple responses of similar question here : stackoverflow.com/questions/1241947/…

    – Shim-Sao
    Nov 24 '18 at 11:05













  • If you use JQuery, you should add : $(document).ready(function() { ... });

    – Shim-Sao
    Nov 24 '18 at 11:09











  • If you use prototype : document.observe("dom:ready", function() { ... });

    – Shim-Sao
    Nov 24 '18 at 11:15











  • I have already tested the DOMContentLoaded event with no success. The link provided suggests to use javascript and explicit rendering ...and it is what i am doing here.

    – mysthiq
    Nov 24 '18 at 11:21
















0












0








0








When i put



<script>
var renderCaptchas = function() {
grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});
};

var onloadCaptchaCallback = function () {
Array.prototype.forEach.call(document.querySelectorAll('.g-recaptcha'),
renderCaptchas);
};
</script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCaptchaCallback&render=explicit" async defer></script>


I have this error :




reCAPTCHA couldn't find user-provided function: onloadCaptchaCallback




The function is yet well defined ...
If i remove



grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});


Then it finds the callback ...
I use the Google ReCaptcha v2, with the checkbox "mode".










share|improve this question














When i put



<script>
var renderCaptchas = function() {
grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});
};

var onloadCaptchaCallback = function () {
Array.prototype.forEach.call(document.querySelectorAll('.g-recaptcha'),
renderCaptchas);
};
</script>
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCaptchaCallback&render=explicit" async defer></script>


I have this error :




reCAPTCHA couldn't find user-provided function: onloadCaptchaCallback




The function is yet well defined ...
If i remove



grecaptcha.render(this, {
'sitekey' : {{ google_recaptcha_site_key }}
});


Then it finds the callback ...
I use the Google ReCaptcha v2, with the checkbox "mode".







recaptcha






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 10:51









mysthiqmysthiq

348




348













  • There is multiple responses of similar question here : stackoverflow.com/questions/1241947/…

    – Shim-Sao
    Nov 24 '18 at 11:05













  • If you use JQuery, you should add : $(document).ready(function() { ... });

    – Shim-Sao
    Nov 24 '18 at 11:09











  • If you use prototype : document.observe("dom:ready", function() { ... });

    – Shim-Sao
    Nov 24 '18 at 11:15











  • I have already tested the DOMContentLoaded event with no success. The link provided suggests to use javascript and explicit rendering ...and it is what i am doing here.

    – mysthiq
    Nov 24 '18 at 11:21





















  • There is multiple responses of similar question here : stackoverflow.com/questions/1241947/…

    – Shim-Sao
    Nov 24 '18 at 11:05













  • If you use JQuery, you should add : $(document).ready(function() { ... });

    – Shim-Sao
    Nov 24 '18 at 11:09











  • If you use prototype : document.observe("dom:ready", function() { ... });

    – Shim-Sao
    Nov 24 '18 at 11:15











  • I have already tested the DOMContentLoaded event with no success. The link provided suggests to use javascript and explicit rendering ...and it is what i am doing here.

    – mysthiq
    Nov 24 '18 at 11:21



















There is multiple responses of similar question here : stackoverflow.com/questions/1241947/…

– Shim-Sao
Nov 24 '18 at 11:05







There is multiple responses of similar question here : stackoverflow.com/questions/1241947/…

– Shim-Sao
Nov 24 '18 at 11:05















If you use JQuery, you should add : $(document).ready(function() { ... });

– Shim-Sao
Nov 24 '18 at 11:09





If you use JQuery, you should add : $(document).ready(function() { ... });

– Shim-Sao
Nov 24 '18 at 11:09













If you use prototype : document.observe("dom:ready", function() { ... });

– Shim-Sao
Nov 24 '18 at 11:15





If you use prototype : document.observe("dom:ready", function() { ... });

– Shim-Sao
Nov 24 '18 at 11:15













I have already tested the DOMContentLoaded event with no success. The link provided suggests to use javascript and explicit rendering ...and it is what i am doing here.

– mysthiq
Nov 24 '18 at 11:21







I have already tested the DOMContentLoaded event with no success. The link provided suggests to use javascript and explicit rendering ...and it is what i am doing here.

– mysthiq
Nov 24 '18 at 11:21














1 Answer
1






active

oldest

votes


















1














There is something strange in your loop for me and grecaptcha.render(this !? this = renderCaptchas ... no !? So the element you want to render is not good because it is not a valid html container.



<script>
var renderCaptchas = function(element) {
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
};
</script>


or something like :



<script>
var onloadCaptchaCallback = function () {
.forEach.call(document.querySelectorAll('.g-recaptcha'), function(element){
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
}
});
};
</script>


How to loop over document.querySelectorAll :



How to loop through selected elements with document.querySelectorAll






share|improve this answer


























  • My code is exactly like your second example, just that i put the function in a more shallow way...

    – mysthiq
    Nov 24 '18 at 15:40











  • I doubt "this" is the html container. Have you try the element as argument ?

    – Shim-Sao
    Nov 24 '18 at 16:15











  • console.log(this) and console.log(element) to this who is right

    – Shim-Sao
    Nov 24 '18 at 16:22











  • I tested element that was indeed a good point but that does not solve the main error.

    – mysthiq
    Nov 24 '18 at 16:39











  • Another error : 'sitekey' : 'your_site_key'

    – Shim-Sao
    Nov 24 '18 at 16:51











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457381%2fhow-can-we-use-several-google-recaptchas-in-the-same-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














There is something strange in your loop for me and grecaptcha.render(this !? this = renderCaptchas ... no !? So the element you want to render is not good because it is not a valid html container.



<script>
var renderCaptchas = function(element) {
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
};
</script>


or something like :



<script>
var onloadCaptchaCallback = function () {
.forEach.call(document.querySelectorAll('.g-recaptcha'), function(element){
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
}
});
};
</script>


How to loop over document.querySelectorAll :



How to loop through selected elements with document.querySelectorAll






share|improve this answer


























  • My code is exactly like your second example, just that i put the function in a more shallow way...

    – mysthiq
    Nov 24 '18 at 15:40











  • I doubt "this" is the html container. Have you try the element as argument ?

    – Shim-Sao
    Nov 24 '18 at 16:15











  • console.log(this) and console.log(element) to this who is right

    – Shim-Sao
    Nov 24 '18 at 16:22











  • I tested element that was indeed a good point but that does not solve the main error.

    – mysthiq
    Nov 24 '18 at 16:39











  • Another error : 'sitekey' : 'your_site_key'

    – Shim-Sao
    Nov 24 '18 at 16:51
















1














There is something strange in your loop for me and grecaptcha.render(this !? this = renderCaptchas ... no !? So the element you want to render is not good because it is not a valid html container.



<script>
var renderCaptchas = function(element) {
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
};
</script>


or something like :



<script>
var onloadCaptchaCallback = function () {
.forEach.call(document.querySelectorAll('.g-recaptcha'), function(element){
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
}
});
};
</script>


How to loop over document.querySelectorAll :



How to loop through selected elements with document.querySelectorAll






share|improve this answer


























  • My code is exactly like your second example, just that i put the function in a more shallow way...

    – mysthiq
    Nov 24 '18 at 15:40











  • I doubt "this" is the html container. Have you try the element as argument ?

    – Shim-Sao
    Nov 24 '18 at 16:15











  • console.log(this) and console.log(element) to this who is right

    – Shim-Sao
    Nov 24 '18 at 16:22











  • I tested element that was indeed a good point but that does not solve the main error.

    – mysthiq
    Nov 24 '18 at 16:39











  • Another error : 'sitekey' : 'your_site_key'

    – Shim-Sao
    Nov 24 '18 at 16:51














1












1








1







There is something strange in your loop for me and grecaptcha.render(this !? this = renderCaptchas ... no !? So the element you want to render is not good because it is not a valid html container.



<script>
var renderCaptchas = function(element) {
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
};
</script>


or something like :



<script>
var onloadCaptchaCallback = function () {
.forEach.call(document.querySelectorAll('.g-recaptcha'), function(element){
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
}
});
};
</script>


How to loop over document.querySelectorAll :



How to loop through selected elements with document.querySelectorAll






share|improve this answer















There is something strange in your loop for me and grecaptcha.render(this !? this = renderCaptchas ... no !? So the element you want to render is not good because it is not a valid html container.



<script>
var renderCaptchas = function(element) {
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
};
</script>


or something like :



<script>
var onloadCaptchaCallback = function () {
.forEach.call(document.querySelectorAll('.g-recaptcha'), function(element){
grecaptcha.render(element, {
'sitekey' : 'google_recaptcha_site_key'
});
}
});
};
</script>


How to loop over document.querySelectorAll :



How to loop through selected elements with document.querySelectorAll







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 24 '18 at 16:53

























answered Nov 24 '18 at 12:02









Shim-SaoShim-Sao

55028




55028













  • My code is exactly like your second example, just that i put the function in a more shallow way...

    – mysthiq
    Nov 24 '18 at 15:40











  • I doubt "this" is the html container. Have you try the element as argument ?

    – Shim-Sao
    Nov 24 '18 at 16:15











  • console.log(this) and console.log(element) to this who is right

    – Shim-Sao
    Nov 24 '18 at 16:22











  • I tested element that was indeed a good point but that does not solve the main error.

    – mysthiq
    Nov 24 '18 at 16:39











  • Another error : 'sitekey' : 'your_site_key'

    – Shim-Sao
    Nov 24 '18 at 16:51



















  • My code is exactly like your second example, just that i put the function in a more shallow way...

    – mysthiq
    Nov 24 '18 at 15:40











  • I doubt "this" is the html container. Have you try the element as argument ?

    – Shim-Sao
    Nov 24 '18 at 16:15











  • console.log(this) and console.log(element) to this who is right

    – Shim-Sao
    Nov 24 '18 at 16:22











  • I tested element that was indeed a good point but that does not solve the main error.

    – mysthiq
    Nov 24 '18 at 16:39











  • Another error : 'sitekey' : 'your_site_key'

    – Shim-Sao
    Nov 24 '18 at 16:51

















My code is exactly like your second example, just that i put the function in a more shallow way...

– mysthiq
Nov 24 '18 at 15:40





My code is exactly like your second example, just that i put the function in a more shallow way...

– mysthiq
Nov 24 '18 at 15:40













I doubt "this" is the html container. Have you try the element as argument ?

– Shim-Sao
Nov 24 '18 at 16:15





I doubt "this" is the html container. Have you try the element as argument ?

– Shim-Sao
Nov 24 '18 at 16:15













console.log(this) and console.log(element) to this who is right

– Shim-Sao
Nov 24 '18 at 16:22





console.log(this) and console.log(element) to this who is right

– Shim-Sao
Nov 24 '18 at 16:22













I tested element that was indeed a good point but that does not solve the main error.

– mysthiq
Nov 24 '18 at 16:39





I tested element that was indeed a good point but that does not solve the main error.

– mysthiq
Nov 24 '18 at 16:39













Another error : 'sitekey' : 'your_site_key'

– Shim-Sao
Nov 24 '18 at 16:51





Another error : 'sitekey' : 'your_site_key'

– Shim-Sao
Nov 24 '18 at 16:51


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457381%2fhow-can-we-use-several-google-recaptchas-in-the-same-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Contact image not getting when fetch all contact list from iPhone by CNContact

count number of partitions of a set with n elements into k subsets

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks