Skip to content

Instantly share code, notes, and snippets.

@ihfazhillah
Created May 22, 2019 07:00
Show Gist options
  • Save ihfazhillah/a5bccade07cd5f021ad6bbe73dc5dd9f to your computer and use it in GitHub Desktop.
Save ihfazhillah/a5bccade07cd5f021ad6bbe73dc5dd9f to your computer and use it in GitHub Desktop.
index.html
// 1
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
// 2
<script src="https://www.google.com/recaptcha/api.js?render=reCAPTCHA_site_key"></script>
<script>
// 3
grecaptcha.ready(function() {
// 4
$('#contactform').submit(function(e){
var form = this;
// 5
e.preventDefault()
grecaptcha.execute('reCAPTCHA_site_key', {action: 'contactform'}).then(function(token) {
// 6
$('#recaptcha').val(token)
// 7
form.submit()
});
})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment