Integrating Google recaptcha V2 to an HTML form

  • Sign up and get your keys here: https://www.google.com/recaptcha/admin (you will get a SITE key and a SECRET key, used later)
  • The following instructions are for integrating recaptcha v2, there is another version also recaptcha V3.
  • While sign up, need to mention the domains and mail id using for this purpose.
  • The recaptcha will only work on the registered domain.
  • Include this on your page:
<script src="https://www.google.com/recaptcha/api.js"></script>

Add the following into your form:

<div class="g-recaptcha brochure__form__captcha" data-sitekey="YOUR SITE KEY"></div>

On form submission:

if (grecaptcha.getResponse() === "") {
					alert("You can't proceed!");
				}

Leave a comment

Your email address will not be published. Required fields are marked *