I want to use recaptcha api but don't want to rewrite this function. My keys are on the submit button and form label. I can see that it doesn't generate the token, just sends the site key. Any help would be great.
Option 1 uses keys in form tags
<form method="POST" name="Form" id="Form" data-sitekey="Form hjkhjkhjkhjk">
Option two uses the key in the button label
<button type="submit" class=g-recaptch "btn btn-primary px-4 float-right" data-sitekey="@reCaptchaKey"> Submit </button>
The goal is to send an ajax request using this method
$("#Form").submit(function(e) { e.stopPropagation(); e.preventDefault(); let formData = this.dataset.sitekey; console.log(formData); let submitter_btn = $(e.originalEvent.submitter); console.log(submitter_btn.data('sitekey')); });
Working example https://jsfiddle.net/tjmcdevitt/8cawy1kb/18/
You must use the
execute
method of thegrecaptcha
object. To do this, you need to add rendering parameters to the reCAPTCHA script load. See Documentation for details.