在IE11中显示Google Recaptcha之后,将调用数据呼叫



获得了一些遗产。详细信息:

我们在我们的网站上有Google recaptcha,通常在表单字段验证以数据为allackback attr。

定义的功能中被调用。
<form class="v_form" id="c-form">
    <div class="label erorr fullName-error" >Please enter your name</div>
    <input type="text" class="simple-input" name="fullName" placeholder="Full name..." required>
    <div class="label">Email*</div>
    <div class="label erorr email-error" >Please enter your e-mail</div>
    <input type="email" class="simple-input" name="email" placeholder="Email..." required>
    <button class="btn send g-recaptcha" data-sitekey="bla-bla" data-callback='onSubmitContact' data-size="invisible">Send!</button>
</form>

在JS中:

function onSubmitContact(){
  ... //some input values validation, if not valid return false - else true;
return false;
}

它在Chrome中运行良好 - 因此,例如,如果任何字段都是空的,那么JS函数返回false,甚至没有显示recaptcha。在IE11中 - 无论如何,它首先显示了recaptcha窗口,我选择了正确的答案 - 然后调用数据查询功能。然后回收错误并停止工作:

SCRIPT5007: Unable to get property 'toString' of undefined or null reference
File: recaptcha__en.js, Line: 376, Column: 41

我可以以某种方式使其在IE中正确工作吗?

我为我的问题找到了解决方法,但请说明:1.我决定在加载事件上实施手动创建Google Recaptcha。

<body onload="onLoad()">
...
<form>
<button class="btn send" id="submit_button">Send!</button>
<div id='recaptcha' class="g-recaptcha"
      data-sitekey="<somekey>"
      data-callback="onSubmit"
      data-size="invisible">
</div>
</form>
...
<script>
function onLoad() {
    window.grecaptcha_id = window.grecaptcha.render('recaptcha', {});
}
function onSubmit(response) { // recaptcha callback
    sendForm();
}
 $('#submit_button').on('click', function (e) {
var error = validateForm(); // validate function, if no error - false
if(error) {
//mark with red, no sending
} else {
grecaptcha.execute(grecaptcha_id);
})
    <script/>
  1. 所以我首先是我自己提交的,然后,如果成功了 - 我跑步grecaptcha.cecute启动recaptcha检查。

备注:

  1. 何时显示在隐藏验证码中选择的图片-Google本身决定。我不能影响这一点。
  2. grecaptcha.reset不起作用。无论我是否称呼它 - 无论如何,recaptcha将Uservalidate请求发送给Google,并且根据回应决定显示验证码。
  3. App Logic中什么都没有改变 - 只是调用recaptcha的另一种方式 - 但是现在我没有IE11中的错误。

最新更新