Skip to content

Instantly share code, notes, and snippets.

@praveencs87
Created November 6, 2020 06:03
Show Gist options
  • Save praveencs87/50e4b2f48e205eb42b8da2354f8d0b10 to your computer and use it in GitHub Desktop.
Save praveencs87/50e4b2f48e205eb42b8da2354f8d0b10 to your computer and use it in GitHub Desktop.
Captcha v3
You can execute reCAPTCHA on as many actions as you want on the same page.
Automatically bind the challenge to a button
The easiest method for using reCAPTCHA v3 on your page is to include the necessary JavaScript resource and add a few attributes to your html button.
Load the JavaScript API.
------------------------------------------------------------------------------------------------------
<script src="https://www.google.com/recaptcha/api.js"></script>
-----------------------------------------------------------
Add a callback function to handle the token.
------------------------------------------------------------
<script>
function onSubmit(token) {
document.getElementById("demo-form").submit();
}
</script>
------------------------------------
Step:3
-------------------------------------
Add attributes to your html button.
<button class="g-recaptcha"
data-sitekey="reCAPTCHA_site_key"
data-callback='onSubmit'
data-action='submit'>Submit</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment