I'm finally at the point of testing my site in other browsers (built it mostly in Chrome). Unfortunately, a lot of stuff seems to function differently. I'll begin with the very first problem: upon login, I have a JS/jQuery check to make sure the username and password match, and upon failure it should stop the submission.
However, while it works in Chrome and Safari, in Mozilla and IE the submission is still going through (hitting an apology page, but still something I'd rather just not see at all).
I've tried subbing out event.preventDefault()
for e.preventDefault()
or evt.preventDefault()
but none of them work, the form still submits (and for the second two it makes it so that it submits in Chrome as well). Here is my code, would love any thoughts:
function checkLogin()
{
// get the variables, execute some other checks (eg, things not blank)
// run ajax code to determine if pieces match
$.ajax({
type: "POST",
url: "check_login.php",
data: {'username': username, 'password': password},
async: false,
success: function(result)
{
if (result == 1)
{
$('#loginoff').html("Invalid username/password");
e.preventDefault();
return false;
}
else
{
$('#loginoff').html("");
return true;
}
}
});
}
Please note that the function is definitely going through and returning 1 when the username and password don't match as, in all cases, the 'Invalid username/password' message is coming up.
Also, in case anybody is interested in the HTML:
<form action="login.php" method="post" onsubmit="return checkLogin()">
<!-- code for inputs, eg username -->
<input type="submit" class="btn" value="Log In"/>
</form>