We can call a function on button click when we are using contact form7. This function will call or work whether your form get submitted or not. To do this follow the instructions below :

Add a jQuery to your page which is required to make this code work.

Add a id to the contact form submit button.

After this put this code in your footer.php :


<script type="text/javascript">

jQuery(document).on("click", "#idforsubmit", function(e) {

alert("hello");//put your desired code here
});

</script>

Where “idforsubmit” is the id of your submit button through contact form7.