Weird input text and input password erasing default input password
I have a simple text and password input with default username and password filled out. If I put focus on the text input and then remove the focus, it erases my password input for some reason. This only seems to happen on firefox开发者_C百科. I thought it would be my surrounding code, but I tried moving everything to a blank page and stripped everything to the bare bones with no luck:
<form>
<input type="text" value="username" />
<input type="password" value="password" />
</form>
A few things I noticed were it doesn't matter what value I change the username and password to, I still get this problem. If I remove the opening form tag, this problem disappears. If I swap it around and put the password first then followed by the username, it will work... Another weird thing is if I run this file from my operating system path the problem also disappears. Anyone have any idea what could be the problem?
Sounds like Firefox's form field auto-completion is getting in your way. You can disable it by adding autocomplete="off"
to the <input>
fields or to the <form>
element to disable it for all fields.
It seems like it is Firefox(at least 3.5.1) Password manager behavior. On blur it looks for very next input field in DOM tree and if there is a password field then manager replaces current value with one what was stored before or with empty string if no matches found.
To ensure it you can try to enter stored for this page/domain user name into input and remove focus. FF will substitute stored password.
As a workaround you can insert <input id="dummy" type="text" style="display:none;" />
between text and pass fields. This will break common markup pattern on which FF relies.
精彩评论