grecaptcha.execute on submit button

821 views
Skip to first unread message

Girish Gosain

unread,
Apr 9, 2019, 5:15:47 PM4/9/19
to reCAPTCHA
I have some forms which may take time to fill, We are facing an issue of token expire before the form is submitted.

I would like to call grecaptcha.execute on form submit event. but here again before I receive a token the form is getting submitted and during the validation we are getting "missing-input-response". Would you please advise how we can use the callback in this case.

Thanks
Girish

Ganesh Kalyan Kommisetti

unread,
May 20, 2019, 5:41:15 PM5/20/19
to reCAPTCHA
Assuming that you are using reCaptcha invisible.
<div class="g-recaptcha" data-sitekey="your_site_key" data-callback="onSubmit" data-size="invisible"></div>
<form action='javascript:grecaptcha.execute()' id='form'>
<!--Your form fields-->
<button class="g-recaptcha" data-sitekey="your_site_key" data-callback='onSubmit'>Submit</button>
</form>
<script>
function onSubmit(token) {
//add code pass token to your server
document
.getElementById('form').submit();
}

</script>
Hope this would help you 
Post for further queries
Reply all
Reply to author
Forward
0 new messages