Stop form refreshing page on submit

Add this onsubmit="return false" code:

<form onsubmit="return false">

That fixed it for me. It will still run the onClick function you specify.


You can prevent the form from submitting with

$("#prospects_form").submit(function(e) {
    e.preventDefault();
});

Of course, in the function, you can check for empty fields, and if anything doesn't look right, e.preventDefault() will stop the submit.

Without jQuery:

var form = document.getElementById("myForm");
function handleForm(event) { event.preventDefault(); } 
form.addEventListener('submit', handleForm);

Replace button type to button:

<button type="button">My Cool Button</button>