How to disable submit button and change text on form submit at Wordpress "contact form 7" - Stack Overflow
Wed Aug 24 2022 10:49:59 GMT+0000 (Coordinated Universal Time)
Saved by
@edujca
// disable button after clicking on submit button
<?php add_action('wp_footer', 'mycustom_wp_footer');
function mycustom_wp_footer()
{
?>
<script type="text/javascript">
jQuery('.wpcf7-form').submit(function() {
jQuery(this).find(':input[type=submit]').prop('disabled', true);
var wpcf7Elm = document.querySelector('.wpcf7');
wpcf7Elm.addEventListener('wpcf7submit', function(event) {
jQuery('.wpcf7-submit').prop("disabled", false);
}, false);
wpcf7Elm.addEventListener('wpcf7invalid', function() {
jQuery('.wpcf7-submit').prop("disabled", false);
}, false);
});
</script>
<?php
}?>
content_copyCOPY
https://stackoverflow.com/questions/53760658/how-to-disable-submit-button-and-change-text-on-form-submit-at-wordpress-contac
Comments