Google Invisible ReCaptcha not invisible

白昼怎懂夜的黑 提交于 2019-12-05 12:06:26

I think your problem is that you are explicitly calling the render() method

recaptchaId = window.grecaptcha.render(htmlEl, captchaOptions, inheritFromDataAttr);

};

if you want it to be invisible, you have to include this custom DIV

    <div class="g-recaptcha"
      data-sitekey="your_site_key"
      data-callback="onSubmit"
      data-size="invisible">
    </div>

https://developers.google.com/recaptcha/docs/invisible

the recaptcha script will look for the div class element and bind it there, then execute the call back when the recaptcha verification is invoked.

to invoke the recaptcha verification use grecaptcha.execute();

follow the example in the googledev page, is pretty straight forward.

I hope that helped =)

I think you are missing the badge parameter in your "captchaOptions".
there are 3 possible values : bottomright (default), bottomleft and inline (which lets you customize the css of the recaptcha).

Looking at the JavaScript API docs, https://developers.google.com/recaptcha/docs/invisible#js_api You need to add a div with an id to render to, the class and data attributes are not required on the button element when you render the captchas with JavaScript.

Your HTML should be:

<form method="post" id="contact-form-face" class="clearfix"   
onsubmit="return false">
    <input type="text" required name="name" value="name" onFocus="if 
    (this.value == 'name') this.value = '';" onBlur="if (this.value == 
    '') this.value = 'name';" />
    <div id="recaptcha"></div>
    <button type="submit" id="sendButton" class="contact_btn" 
    onclick="onSubmitBtnClick()"value="send">send</button>
</form>

And Your JS should be updated to:

// element to "render" invisible captcha in
var htmlEl = 'recaptcha'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!