run script before form action with post code example
Example 1: buttons js before submit
$('#myform').submit(function() {
// DO STUFF...
return true; // return false to cancel form action
});
Example 2: buttons js before submit
<form id="myform">
...
</form>