views:

507

answers:

3

I'm having a hard time figuring out how Firefox and Chrome determining what fields are for a password and how they autocomplete them on other forms.

For my login form, I have this:

<p>
    <label for="login_email">Email:</label><br />
    <input id="login_email" name="login[email]" size="30" type="text">
</p>

<p>
    <label for="login_password">Password:</label><br />
    <input id="login_password" name="login[password]" size="30" type="password">
    <input id="login_password_hash" name="login[password_hash]" type="hidden">
</p>

<p>
    <input id="login_submit" value="LOGIN" type="submit">
</p>

The login_password_hash field is for hashing the password on client side before sending using Javascript, having Javascript disabled does not change the outcome.

And for creating a new user, I have this form:

<p>
    <label for="user_email">Email:</label>
    <input id="user_email" name="user[email]" size="30" type="text">
</p>
<p>
    <label for="user_first_name">First Name:</label>
    <input id="user_first_name" name="user[first_name]" size="30" type="text">

</p>
<p>
    <label for="user_last_name">Last Name:</label>
    <input id="user_last_name" name="user[last_name]" size="30" type="text">
</p>
<p>
    <label for="user_password">Password:</label>
    <input id="user_password" name="user[password]" size="30" type="password">
    <input id="user_password_hash" name="user[password_hash]" type="hidden">
</p>

<p><input id="user_submit" value="Create User" type="submit"></p>

Now after saving the password from the login form and visiting the new user form, the saved email is put in the last field before the password field and puts the password in the password field.

This happens on Firefox and Chrome, but not in Internet Explorer. Any ideas on why Firefox and Chrome behave this way? The two forms have nothing in common, the names and ids are all different.

A: 

Well all browsers are going to pick up the most obvious field names:

  • firstname
  • lastname
  • username
  • password

And the obvious alternates of those (underscores for spaces, and some shorthand such as "user" and "pass" maybe). It's going to be up to the browser itself and what version of it as to what crazy alternates are supported.

TravisO
Changing both the id and name attributes on both email and password fields to complete gibberish still has Firefox and Chrome autocomplete both forms.
Samuel
+1  A: 

If you want to disable autocomplete on an input, try using the autocomplete attribute, e.g.:

<input type="text" name="email" autocomplete="off" />

This is not guaranteed to work in all browsers, however.

RedFilter
I want autocomplete for the login page, but thanks for the suggestion.
Samuel
A: 

Seems that changing name and id attributes has no effect on the password managers in Firefox and Chrome, all they see is a password_field and the field above it and that is good enough for them.

So I'm just making the password field in create a new user as a text field.

Samuel
This seems to be a known issue.http://code.google.com/p/chromium/issues/detail?id=1854
kripto_ash