Why does this form submit on click of the submit button
<pre><code>&lt;script type="text/javascript"&gt;
var geid = function(x) {
        var element = document.getElementById(x);
        return element;
     }          


function submitForm(){
var password = geid('password').value; 
var passwordConfirm = geid('passwordConfirm');

//THIS IS OF HIGH IMPORTANCE THAT THIS CONFIRM PASSWORD MATCHES
//WILL NEED TO VALIDATE IT IN THE PHP AS WELL&gt;
else if (password == ""){
    registerMessage.innerHTML = "Please enter your Password.";
    return false;  
}
else if (passwordConfirm == "") {
    registerMessage.innerHTML = "Please confirm your password.";            
    return false; 
}

else if (passwordConfirm != password) {
    registerMessage.innerHTML = "Your passwords don't match.";          
    return false; 
}
else {
     registerMessage.innerHTML = "Taking you to your profile, please wait a moment...";
     document.forms['registerform'].submit();
}
}

   &lt;form method="post" action="register.php" id="registerform" onsubmit="return submitForm()"&gt;


     &lt;label for="password" class="registerLabel"&gt;Password&lt;/label&gt;
     &lt;input type="password" name="password" id="password" class="registerText" /&gt; &lt;br /&gt;

     &lt;label for="passwordConfirm" class="registerLabel"&gt;Confirm Password&lt;/label&gt;
     &lt;input type="password" name="passwordConfirm" id="passwordConfirm" class="registerText" /&gt; &lt;br /&gt;


        &lt;div class="submitMessage"&gt;
            &lt;input type="submit" id="submit" name="submit" value="Register" class="registerButton cleangray" /&gt;&lt;br /&gt;
            &lt;div id="registerMessage"&gt;&lt;?php echo $error ?&gt;&lt;/div&gt;  
        &lt;/div&gt;

        &lt;div class="clear"&gt;&lt;/div&gt;

    &lt;/form&gt;
</code></pre>
