Closed DmitrySkibitsky closed 6 years ago
documentation:
grecaptcha.reset(
opt_widget_id
)
js:
<script type="text/javascript">var buzzNoCaptchaOnLoadCallback = function() {
grecaptcha.render('buzzNoCaptchaId_d649ff40713a7502e18656d207b2a63a',
{"sitekey":"6LdVmDEUAAAAABEyMLp_V2Yr52KOYC19aovieDuE","size":"compact"});
grecaptcha.render('buzzNoCaptchaId_89a13a9628c631ad4b732a0d4dd10059',
{"sitekey":"6LdVmDEUAAAAABEyMLp_V2Yr52KOYC19aovieDuE","size":"compact"});};
</script>
grecaptcha.reset('buzzNoCaptchaId_89a13a9628c631ad4b732a0d4dd10059');
error:
Uncaught Error: Invalid reCAPTCHA client id:
buzzNoCaptchaId_ada85a4805ccd5f01fbaef982e793c82
at Object.Nr [as reset]
How to reset a specific captcha?
We had to change the generation of js. Assign variable + i = grecaptcha.render. And after doing grecaptcha.reset (variable + i);
i think will be create buzzNoCaptchaWidgetIds
js variable and assign widget with key is html id.
i will flow document
Thanks you
Looking forward to a fix. Cannot use this package while resetting not supported.
feature has been added in v2.1.8, you can try example on examples folder I hope useful to you
@JanisE @thinhbuzz https://github.com/thinhbuzz/laravel-google-captcha/blob/v2.1.8/examples/single.blade.php Yes, it is resets but not in the case when there is a lot of recaption on the page.
This is how I had to fix the source package.
<script type="text/javascript">
var widget0 = grecaptcha.render('buzzNoCaptchaId_68a178f1c108a02f32d2b823b46272fe',
{
"sitekey":"6LdVmDEUAAAAABEyMLp_V2Yr52KOYC19aovieDuE",
"size":"compact"
});
var widget1 = grecaptcha.render('buzzNoCaptchaId_06055679c6ca78d57dddfdaedc52ec66',
{
"sitekey":"6LdVmDEUAAAAABEyMLp_V2Yr52KOYC19aovieDuE",
"size":"compact"
});
</script>
function resetRecaptcha() {
if (typeof widget0 !== 'undefined') {
grecaptcha.reset(widget0);
}
if (typeof widget1 !== 'undefined') {
grecaptcha.reset(widget1);
}
}
But this in haste, as it was necessary to quickly fix the reset. A bit later I plan to add a more customized solution. Where in $attributes the name of the widget will be transferred and after that the widget will be sent to the reset function, which should be reset for example after the Ajax request failed validation.
you want show multiple captcha on page and able reset it? check here multiple.blade.php
I apologize. Everything, revised examples and changes. Thank you.
You can close it.) The problem is solved.
Please give an example of how you reset the captcha if there are several of them on the page. I have not tried it all the same.