Google reCAPTCHA

by Lasith De Silva

HTML

<script src="https://www.google.com/recaptcha/api.js"></script>
<div class="container">
    <div id="recaptcha"></div>
</div>
<div id="email">
Verify captcha to get e-mail
</div>

JavaScript

function createRecaptcha() {
	grecaptcha.render("recaptcha", {sitekey: "6LcgSAMTAAAAACc2C7rc6HB9ZmEX4SyB0bbAJvTG", theme: "light", callback: test});
}
 createRecaptcha();

function test() {
	// ideally you would do server side verification of the captcha and then the server would return the e-mail
  document.getElementById("email").innerHTML = "[email protected]";
}