no-captcha
no-captcha copied to clipboard
Multiple recaptcha on same page
Multiple recaptcha on same page is not showing. How can i do this?
Just youse this for each captcha at the page if you need dynamic including:
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
async defer>
</script>
<div class="g-recaptcha"></div>
<script>
var onloadCallback = function() {
//remove old
$('.g-recaptcha').html('');
$('.g-recaptcha').each(function (i, captcha) {
grecaptcha.render(captcha, {
'sitekey' : 'your key'
});
});
};
</script>
But it is slow. You can also define all recaptchas at page initially: https://developers.google.com/recaptcha/docs/display
Check my version, work with Multiple recaptcha. https://github.com/dosarkz/no-captcha
This does the trick for me, no jquery dependency, ie9+:
{!! NoCaptcha::renderJs('en', true, 'recaptchaCallback') !!}
<script>
function recaptchaCallback() {
document.querySelectorAll('.g-recaptcha').forEach(function (el) {
grecaptcha.render(el);
});
}
</script>