Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set the badge position with reCAPTCHA v3?

Tags:

recaptcha

I would like to use an inline badge with v3, but there is no documentation on badge position for v3.

like image 384
Still don't know everything Avatar asked May 29 '18 11:05

Still don't know everything


People also ask

How do I change the position in reCAPTCHA?

You can easily use PHP to change the default position. When using Google's v2 Invisible reCAPTCHA, there is a badge that will show in the bottom right corner of the webpage. By default, the position is always set to bottomright. With a small code snippet you can change this position to either bottomleft or inline.

How do I hide reCAPTCHA v3 badge?

So how to hide the reCaptcha v3 badge? As reported on stack overflow the spam check is not working properly using the code “display:none;”. In addition, you can also use the code “visibility:hidden;” to hide the reCaptcha v3 badge.

What is a good score for reCAPTCHA v3?

reCAPTCHA v3 returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot). Based on the score, you can take variable action in the context of your site. Every site is different, but below are some examples of how sites use the score.

Can I run reCAPTCHA v2 and v3 on the same page?

Yes, you can use both reCAPTCHA (non-Enterprise version) and reCAPTCHA Enterprise. Typically the third party solution asks for your public key and either your secret key or your API key.


1 Answers

You can make the badge inline in V3 with just Javascript it's just not documented yet.


Set your `render` parameter to `explicit` and add a `onload` parameter for the callback, `onRecaptchaLoadCallback` for example.
<script src="https://www.google.com/recaptcha/api.js?render=explicit&onload=onRecaptchaLoadCallback"></script> 

Then set up your callback like so and don't forget to enter the id/DOM node of where you want your badge to go, in this case, the id is inline-badge.

<script>     function onRecaptchaLoadCallback() {         var clientId = grecaptcha.render('inline-badge', {             'sitekey': '6Ldqyn4UAAAAAN37vF4e1vsebmNYIA9UVXZ_RfSp',             'badge': 'inline',             'size': 'invisible'         });          grecaptcha.ready(function() {             grecaptcha.execute(clientId, {                     action: 'action_name'                 })                 .then(function(token) {                     // Verify the token on the server.                 });         });     } </script> 

Example

Source

Note: Valid values for 'badge' are 'inline', 'bottomleft', 'bottomright', and 'bottom'. 'bottom' and 'bottomright' are synonyms.

like image 106
Sam Carlton Avatar answered Sep 28 '22 08:09

Sam Carlton