Why does my Jquery command not stop the form submission process?
<p>I get the error message that confirms passwords do not match but my database still adds a new listing! What do I need to do in order to make the script stop the form from submitting? My understanding of coding is very weak! </p>

<pre><code>&lt;script src="scripts/jquery.js" type="text/javascript"&gt;
jQuery(function(){
  $("#submit").click(function(){
    $(".error").hide();
    var hasError = false;
    var passwordVal = $("#password").val();
    var checkVal = $("#repeatpassword").val();
    if (passwordVal == '') {
      $("#password").after('&lt;span class="error"&gt;Please enter a password.&lt;/span&gt;');
      hasError = true;
    } else if (checkVal == '') {
      $("#repeatpassword").after('&lt;span class="error"&gt;Please re-enter your password.&lt;/span&gt;');
      hasError = true;
    } else if (passwordVal != checkVal ) {
      $("#repeatpassword").after('&lt;span class="error"&gt;Passwords do not match.&lt;/span&gt;');
      hasError = true;
    }
    if(hasError == true) {return false;}
  });
});
&lt;/script&gt;
&lt;form method="post" name="form1" action="&lt;?php echo $editFormAction; ?&gt;"&gt;
  &lt;table align="center"&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;First name:&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="firstname" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Last name:&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="lastname" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Email:*&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="email" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Password:*&lt;/td&gt;
      &lt;td&gt;&lt;input type="password" name="password" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Repeat Password:*&lt;/td&gt;
      &lt;td&gt;&lt;input type="password" name="repeatpassword" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right" valign="top"&gt;Channel url:*&lt;/td&gt;
      &lt;td&gt;&lt;textarea name="channelurl" cols="50" rows="1"&gt;&lt;/textarea&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Channel name:*&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="chanelname" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Description:&lt;/td&gt;
      &lt;td&gt;&lt;textarea name="description" cols="32" rows="6"&gt;&lt;/textarea&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Video 1:* &lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="embedd1" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;What game is it?&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="game1" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Video 2:&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="Embedd2" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;What game is it?&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="game2" value="" size="32"&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;Keywords to describe and find your channel*&lt;/td&gt;
      &lt;td&gt;&lt;input type="text" name="keywords" value="" size="32"&gt;&lt;/td&gt;  
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap align="right"&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&lt;input type="submit" value="Channel Create"&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;input type="hidden" name="chanelID" value=""&gt;
  &lt;input type="hidden" name="MM_insert" value="form1"&gt;
&lt;/form&gt;
</code></pre>
