cript> $('input#g-recaptcha-response').closest('form').submit(function(event) { event.preventDefault(); var that = $(this), tempElement = $(""), button = that.find('[type=submit]'); tempElement .attr("name", button.attr('name')) .val(button.val()) .appendTo(that); grecaptcha.ready(function() { grecaptcha.execute('6Lfc19chAAAAAMKdTmkALdHsDDUZtQ94Amo7vuQ9', { action: 'formSubmit' }).then(function(token) { $('input#g-recaptcha-response').attr('value', token); that.off('submit').submit(); }); }); });