Created
May 25, 2021 19:05
-
-
Save uprise10/ed72c62c071a369fddb2434f419978ae to your computer and use it in GitHub Desktop.
Prevent double click on submit button in Gravity Forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'gform_enqueue_scripts', 'your_prefix_add_scripts' ); | |
function your_prefix_add_scripts($form) { | |
echo '<script> | |
document.addEventListener( "DOMContentLoaded", function( e ) { | |
if ( typeof jQuery !== "undefined" ) { | |
jQuery(document).on( "click", "#gform_' . $form['id'] . ' [type=submit]", function(e) { | |
if( jQuery(this).data("isclicked" ) === true ) { | |
e.preventDefault(); | |
return false; | |
} | |
jQuery(this).css("opacity", 0.2).data("isclicked", true); | |
}); | |
} | |
}); | |
</script>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment