Good Day,
We are using the code snippet provided by Gravity Forms (see below) to change the text of our “Send” button on click.
The filter works great except for the reCaptcha field – which has been added on our form.
Specifically, when we click the"Send" button and some fields are left blank (except the reCaptcha field), the text changes to “Sending…” but the green checkmark inside reCaptcha’s checkbox is lost (i.e., the reCaptcha field resets itself).
Details: Screenshot by Lightshot
How can we modify the code snippet provided below to ensure the reCaptcha’s green checkmark is not lost?
Thank you,
Jonathan
Note: We’re using a button text filter for our MailPoet forms and it works great for our MailPoet form reCaptcha checkbox.
Code Snippet to Change Button Text on Click:
add_filter( ‘gform_submit_button’, ‘gf_change_submit_button_text’, 10, 2 );
function gf_change_submit_button_text( $button, $form ) {
$dom = new DOMDocument();
$dom->loadHTML( ‘<xml encoding=“utf-8” ?>’ . $button );
$input = $dom->getElementsByTagName( ‘input’ )->item(0);
$onclick = $input->getAttribute( ‘onclick’ );
$onclick .= " this.value=‘Sending…’"; // Change button text when clicked.
$input->setAttribute( ‘onclick’, $onclick );
return $dom->saveHtml( $input );
}