Reputation: 51751
Often on a website, if I enter the wrong password by mistake, I get a page back that indicates the wrong credentials, but Chrome (Or whatever) prompts me with "Would you like to remember this password?"
Is there any way to hint to the browser that now is not the time to ask, so that it only prompts if the user enters a correct password?
Upvotes: 15
Views: 871
Reputation: 7351
You could use JQuery & Ajax to post the login form to the server and recieve a response back without ever reloading the page, thus avoiding this problem altogether.
EDIT
Something along the lines of this (untested):
<div id="error"></div>
<form id="loginForm" method="post">
<input type="username" name="username" id="username">
<input type="password" name="password" id="password">
<input type="submit" value="Login">
</form>
<script>
$(function(){
$('#loginForm').submit(function(){
// Ajax to check username/pass
$.ajax({
type: "POST"
, url: "/login"
, data: {
username: $('#username').val()
, password: $('#password').val()
}
, success: function(response) {
if(response == 'OK'){
$('#loginForm').submit()
} else {
$('#error').html('Invalid username or password')
}
}
})
})
</script>
Upvotes: 8
Reputation: 152956
No. The browser displays the message at the moment the form is submitted. It doesn't wait for the server's response, so there's no way to tell wether or not the password is correct.
Slightly related:
Upvotes: 2