Validate form before button click
<p>I have a form on the contact page which i want to validate before the user clicks the submit button.</p>

<pre><code>&lt;form id="contact" name="f1" action="mail.php" onsubmit="validate()"&gt;
</code></pre>

<p>I have Javascript code which does validation of fields. But, when i click on the button the  user is redirected to 'mail.php' without doing validation.</p>
