检查是否存在reCaptcha,如果不这样做

时间:2018-10-30 14:23:29

标签: javascript recaptcha grecaptcha

我正在尝试检查页面上是否存在reCaptcha,如果不存在,请执行其他操作

到目前为止,我的代码是这样的

     _reCaptchaHandler = function () {
    $("form.get-in-touch, form.request-a-demo, form.single-step-form").on('click','input[type="submit"]',function(e) {
        getCurrentform = $(this).parents('form');

        if(getCurrentform.valid() === true){
            e.preventDefault();
            console.log(" grecaptcha present");
            grecaptcha.reset();
        };

        if (isNone(window.grecaptcha) || isNone(window.grecaptcha.render)) {
            e.preventDefault();
            grecaptcha.reset();
            console.log("grecaptcha NA");

        };
        console.log(" grecaptcha no here");
    });
}

该页面上不存在grecaptcha剂量,因此我希望获得 grecaptcha NA ,但是我得到

>  grecaptcha present
  Uncaught Error: No reCAPTCHA clients exist.
at hd (recaptcha__en.js:499)
at Object.f9 [as reset] (recaptcha__en.js:494)
at HTMLInputElement.<anonymous> (form-wffm.js:190)
at HTMLFormElement.dispatch (jquery.js:4737)
at HTMLFormElement.elemData.handle (jquery.js:4549)

如何编辑我的代码,以便在不存在grecaptcha的情况下,如果

0 个答案:

没有答案