tags:

views:

275

answers:

2

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. 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?

+1  A: 

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.

John Kugelman
Hmm, this "somewhat" works. After using autocomplete="off", what happens is that when I put focus on the username, now the password doesn't get erased. However, once I type anything in the username and lose focus, it erases the password again. This is puzzling because I tried a few other sites and this doesn't happen.
Roger
A: 

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.

Yuri Kovzel