if (!google_recaptcha_site_key) { return; } var $form = $('#form_input'); $('.button_submit', $form).click(function(e){ e.preventDefault(); grecaptcha.ready(function(){ grecaptcha.execute(google_recaptcha_site_key, {action: google_recaptcha_action}).then(function(token){ $form.append($('').val(token)) .submit(); }); }); });