maintain password value after failed login attempt I'm working on a custom login page for users. I have some special elements on the page, which might cause authentication to fail even though a user enters a valid username and password combination. 

After a failed authentication attempt, the username field still keeps the username they entered, but the password field is blank. I would like the password field to keep its value, like the username field does.

I'm starting the form with user_login(). I added a check to add in the password:

if (isset($form_state['input']['pass']) ) {
// user has submitted the login form once.

 // maintain their entered password
  $form['pass']['#default_value'] = $form_state['input']['pass'];
}


Yet it doesn't survive. 

How can I re-populate the password field after a failed login?
The password field doesn't use the "#default_value" property. This means that is not possible to pre fill the field with a default value as it is possible with a textfield field. As it is not possible to set a default value for the field, a password field is always shown empty.  

It is what I would expect, especially when a validation handler returns an error for the entered password. If the password is wrong, I don't see any reason to pre fill the field with what previously entered, considering that what the user sees is something similar to "•••••" (or a group of asterisks).