Skip to content

Instantly share code, notes, and snippets.

@neilmaledev
Created July 7, 2017 02:34
Show Gist options
  • Save neilmaledev/4e2d6eacf29da04043f951c56a4ce07b to your computer and use it in GitHub Desktop.
Save neilmaledev/4e2d6eacf29da04043f951c56a4ce07b to your computer and use it in GitHub Desktop.
Step 1: Register for google recaptcha here: https://www.google.com/recaptcha/intro/
Step 2: You can follow the official instruction there or continue reading my simplified instruction
Step 3: Include the google recaptcha api at the bottom of your html head tag
<head>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
Step 4: Include google recaptcha at the very end of your html form with the generated key from Step 1
<form>
<div class="g-recaptcha" data-sitekey="this-is-a-generated-key-from-step-1"></div>
</form>
/* API <script> functions */
/*
*Check if google recaptcha is valid
*@return int (0: invalid, >=1: valid )
*/
grecaptcha.getResponse().length
/* Reset the google recaptcha, will make it invalid again */
grecaptcha.reset();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment