Login form: enter username, autocomplete password

I need a login form where I just need to enter my username so that it remembers my password and automatically fills in the password field (for example, as in gmail auth).

How could I achieve this?

thanks

Luke

+4
source share
3 answers

This type of behavior is usually determined by the browser. However, there are a few things you can do to improve this behavior.

Make sure you use descriptive names for your form.

<label for="username">Username</label><input type="text" name="username" /> <label for="password">Password</label><input type="password" name="password" /> 

Using these names can really make a difference. For example, I use the Opera browser, and in my settings I set several values. For example, "name", "address", "phone number". And the opera will look for fields that have equivalent names, and I can let Opera populate it for me.

The following two things are only supported in Internet Explorer, and I would not advise them to implement without thinking about it.

I mean, I think it doesn't harm them. It just gives a little more support to Internet Explorer users, but I will not rely on them.

Internet Explorer also supports the autocomplete attribute, which you can control whether IO should autocomplete input . You can use it as

 <input type="text" name="username" autocomplete="on" /> <!--Enabled--> <input type="text" name="username" autocomplete="off" /> <!--Disabled--> 

Also (IE function only, I think ...) is vCards support. You can add the VCARD_NAME attribute, and it allows the browser to populate the corresponding vCard value. for instance

 <input type="text" name="email" VCARD_NAME="vCard.Email" /> 
+4
source

Gmail does not autocomplete a password; this is what your browser does.

Which may help to use something like LastPass , but you need to leave it to individual users regardless of whether they want to remember their password.

0
source

Note for people not to bang their heads against the wall: Chrome will not save and offer passwords on untrusted sites.

Thus, if you test on a local server at https://localhost and have not created a valid and trusted certificate, you will not be able to test this Chrome feature.

0
source

All Articles