【问题标题】:data-callback function not working in Invisible reCAPTCHA数据回调函数在 Invisible reCAPTCHA 中不起作用
【发布时间】:2017-06-23 11:57:27
【问题描述】:

我已经在一个网站中实现了 Invisible reCAPTCHA 用于注册表单。当我单击提交按钮时,reCAPTCHA 将出现,并且在验证后它不会调用回调函数。 这是脚本。

脚本

 {literal}
 <script src="https://www.google.com/recaptcha/api.js" async defer></script>
 <script>
 function onSuccess = function(token) {
 document.getElementById("registerform").submit();
 }
 </script>
{/literal}

HTML

<form action="" method="post" name="registerform" id="registerform" onsubmit="javascript: return checkRegFormFields(this);">
<td colspan="2" class="button-row">
<button class="btn main-button btn-danger no-bdrs btn-block btn-lg g-recaptcha" data-sitekey="mysitekey" data-callback="onSuccess"  title="Submit">  Submit </button>
</td>

【问题讨论】:

    标签: javascript invisible-recaptcha


    【解决方案1】:

    这里你可能会发生两件事。

    1) 当您点击提交按钮时,您的回调未注册。

    先用回调命令你的脚本,然后在 html 中 recaptcha api 如下 -

    (供参考:https://developers.google.com/recaptcha/docs/invisible#explicit_render

    {literal}
     <script>
     function onSuccess = function(token) {
     document.getElementById("registerform").submit();
     }
     </script>
     <script src="https://www.google.com/recaptcha/api.js" async defer></script>
    {/literal}
    

    2) 或者,如果注册了回调,那么 google 会将您检测为机器人,因此不会调用数据回调,那么在这种情况下,您一定会收到验证码图像挑战。

    只有在验证成功时才会调用数据回调。

    希望这会有所帮助..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 2010-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多