Form gets submitted even if validation fails
<p>I want the username and password to be <code>admin</code> &amp; <code>admin</code> respectively so as to successfully submit the form. But the form gets submitted even if username and password to not match <code>admin</code> &amp; <code>admin</code>.</p>

<pre><code>function validateOnSubmit() {

    console.log("Called!");
    var isValid = true;

    document.getElementById("alert").className = "";
    if (document.getElementById("login-password").value.length &lt;= 4) {
        isValid = false;
        document.getElementById("alert").className = "doWiggle";
        setTimeout(function(){
            document.getElementById("alert").className = document.getElementById("alert").className.replace('doWiggle', '');
        }, 300);
    }else
    {
        if(document.getElementById("login-password").value != "admin" &amp;&amp; document.getElementById("username").value != "admin") {
            alert("Wrong Password!");
            isValid = false;
        }
    }
    console.log(isValid);
    return isValid;
}
</code></pre>

<p><br>
<code>HTML</code></p>

<pre><code>    &lt;div class="container"&gt;
    &lt;form action="home.html" id="login-form" method="post" onsubmit="return validateOnSubmit()"&gt;
    &lt;p class="form-header"&gt;Sign In&lt;/p&gt;
        &lt;span&gt;Username&lt;/span&gt;
        &lt;br/&gt;
        &lt;input type="text" name="username" id="username" autocomplete="off" required/&gt;

        &lt;br/&gt;
        &lt;br/&gt;

        &lt;span&gt;Password&lt;/span&gt;
        &lt;br/&gt;
        &lt;input type="password" name="login-password" id="login-password" onkeyup="return validate()" required/&gt;
        &lt;p id="alert"&gt;Password should more than 4 characters!&lt;/p&gt;
        &lt;br/&gt;
        &lt;br/&gt;

        &lt;input type="checkbox" name="rememberMe" class="rememberMe" id="rememberMe"/&gt;
        &lt;label for="rememberMe"&gt;Remember Me&lt;/label&gt;

        &lt;br/&gt;
        &lt;br/&gt;

        &lt;input type="submit" id="submit" value="Sign In"/&gt;
        &lt;br&gt;
        &lt;br&gt;
        &lt;div id="options"&gt;
            &lt;a href="register.html"&gt;Not registered ?&lt;/a&gt;
        &lt;/div&gt;
        &lt;input type="hidden" name="operation" value="login"&gt;
    &lt;/form&gt;
    &lt;/div&gt;
    &lt;script type="text/javascript" src="js/validate.js"&gt;&lt;/script&gt;
&lt;/body&gt;
</code></pre>