I want to use recaptcha api but didn't want to rewrite this function. I have the key on the submit button and on the form tag. I can see its not generating the tokens just sending the sitekey. Any help would be great.
option one using the key in the form tag
<form method="POST" name="Form" id="Form" data-sitekey="Form hjkhjkhjkhjk">
option two using the key in the button tag
<button type="submit"
class=g-recaptch "btn btn-primary px-4 float-right"
data-sitekey="@reCaptchaKey">
Submit
</button>
Goal is use this method for sending ajax request
$("#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 sample https://jsfiddle.net/tjmcdevitt/8cawy1kb/18/
You have to use
executemethod ofgrecaptchaobject. To do this, you need to add a render parameter to the reCAPTCHA script load. For details see the documentation.