Submit the form only if email is valid
<p>I need a way to submit a form only if email is valid. If email is NOT valid then show ONLY an alert ( below you can see my code ).</p>

<p>JAVASCRIPT:</p>

<pre><code> function validateEmail(email) { 
    var re = /^(([^&lt;&gt;()[\]\\.,;:\s@\"]+(\.[^&lt;&gt;()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
 } 


 function continueornot() {
    if(validateEmail(document.getElementById('emailfield').value)){
    // ok
    }else{ alert("email not valid"); return false;}
 }
</code></pre>

<p>HTML:</p>

<pre><code>&lt;form method="post" action="register.php" enctype="multipart/form-data"&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;Email:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;input type="text" size="30" name="email" id="emailfield"&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Password:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;&lt;input type="password" size="30" name="password"&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;input name="steptwo" value="Create Account" type="submit" onclick="continueornot();"/&gt;
&lt;/form&gt;
</code></pre>

<p>The problem is that the form is submitted even if the email is NOT valid. </p>

<p>How can I resolve this problem ?</p>
