 <p>When you change your submit to this it won't submit if RequiredFields returns <code>false</code>.</p> <pre><code>&lt;input type="submit" value="Login" onsubmit="return RequiredFields();"/&gt; </code></pre>