Skip to content

Instantly share code, notes, and snippets.

@mikeott
Last active August 25, 2022 06:14
Show Gist options
  • Save mikeott/d9a991b647fb56531409fbd8083c2da1 to your computer and use it in GitHub Desktop.
Save mikeott/d9a991b647fb56531409fbd8083c2da1 to your computer and use it in GitHub Desktop.
Verify Recaptcha
<script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer></script>
<form>
<div id="re-captcha"></div>
<input type="submit" value="Submit" id="contactFormSubmit" value="Submit" disabled />
</form>
<script>
var actCallback = function (response) {
$('#contactFormSubmit').prop('disabled', false);
$('#re-captcha').remove();
};
var expCallback = function() {
$('#contactFormSubmit').prop('disabled', true);
};
var onloadCallback = function () {
var widget = grecaptcha.render(document.getElementById('re-captcha'), {
'sitekey' : 'YOUR-SITE-KEY',
'theme': 'light',
'callback' : actCallback,
'expired-callback': expCallback,
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment