admin管理员组文章数量:1323716
I am implementing the Recaptcha V3 on my site, and I could not find a proper way to reset the token if my request has failed.
Following the documentation, to load the recaptcha I need to include the following script on my page:
<script src='.js?render=MY_KEY'></script>
Also I am binding the captcha token to a field, to validate on my back end when the customer choose to send an e-mail:
grecaptcha.ready(function() {
grecaptcha.execute('MY_KEY', {
action : 'homepage'
}).then(function(token) {
$("#recaptcha").val(token);
});
});
So I have mainly two steps:
- Validate the captcha
- Send the e-mail
If some error occur during the second step, I was unable to find a way to reset the current captcha on the page, since it was already validated if I try again it is no longer valid.
I have tried the grecaptcha.reset()
, but without the widgetId
the following message appears: Uncaught Error: No reCAPTCHA clients exist.
How can I get the widget id when rendering through the script?
I am implementing the Recaptcha V3 on my site, and I could not find a proper way to reset the token if my request has failed.
Following the documentation, to load the recaptcha I need to include the following script on my page:
<script src='https://www.google./recaptcha/api.js?render=MY_KEY'></script>
Also I am binding the captcha token to a field, to validate on my back end when the customer choose to send an e-mail:
grecaptcha.ready(function() {
grecaptcha.execute('MY_KEY', {
action : 'homepage'
}).then(function(token) {
$("#recaptcha").val(token);
});
});
So I have mainly two steps:
- Validate the captcha
- Send the e-mail
If some error occur during the second step, I was unable to find a way to reset the current captcha on the page, since it was already validated if I try again it is no longer valid.
I have tried the grecaptcha.reset()
, but without the widgetId
the following message appears: Uncaught Error: No reCAPTCHA clients exist.
How can I get the widget id when rendering through the script?
Share Improve this question asked Dec 23, 2018 at 18:42 nortontguenonortontgueno 2,8211 gold badge27 silver badges38 bronze badges1 Answer
Reset to default 7As I understand from Recaptcha V3 you have to call execute again try to do it like this
let createNewToken = () => {
grecaptcha.ready(function() {
grecaptcha.execute('code', {action: 'homepage'}).then(function(token) {
console.log(token);
});
});
}
本文标签: javascriptGoogle Recaptcha V3Widget Id when loading captcha through URLStack Overflow
版权声明:本文标题:javascript - Google Recaptcha V3 - Widget Id when loading captcha through URL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742126195a2421952.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论