I am using Ajax and Php to validate a user's login.. But form onsubmit is not working..
<form action="loggedin.php" onsubmit="return test()" method="post">
Javascript
function test(){
    var a = document.getElementById("email").value;
    var b = document.getElementById("pwd").value;                
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function(){
    if(this.readyState == 4 && this.status == 200){
        var resp = this.responseText;
        if(resp != "Correct"){
            document.getElementById("email").value = "";
            document.getElementById("pwd").value = "";
            document.getElementById("passdiv").style.display = "block";
            return false;
        }
        else{
            return true;
        }
    }
    else{
        return false;
    }
    };
    xmlhttp.open("POST","check.php",true);
    xmlhttp.send("email=" + a + "&passwd=" + b);
}
Why is it not working?
 
    