Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML login form : provide username,autofill password

I need a login form where I just need to provide my username,cause it will remember my password and automatically fill in the password field (Ex. Like in gmail auth).

How could I achieve that?

thanks

Luca

like image 377
luca Avatar asked Apr 19 '11 07:04

luca


People also ask

How should I store my username and password in HTML?

On submit javascript posts the username and password to a php script on the server which returns 'true' or 'false'. When the authentication returns true the app changes the html5 page and stores the username and password in html5 local storage.

How do you autocomplete in HTML?

The autocomplete attribute specifies whether a form or an input field should have autocomplete on or off. Autocomplete allows the browser to predict the value. When a user starts to type in a field, the browser should display options to fill in the field, based on earlier typed values.


2 Answers

A note for people to avoid banging their heads against the wall: Chrome won't save and suggest passwords on untrusted sites.

As such, if you are testing on your local server at https://localhost, and you haven't generated a valid and trusted certificate, you won't be able to test this feature of Chrome's.

like image 147
Vic Seedoubleyew Avatar answered Oct 07 '22 22:10

Vic Seedoubleyew


This type of behavior is usually defined 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. I for example use the Opera browser, and in my settings, I've set a few values. For example "name", "address", "telephone number". And opera will look for fields that have equivalent names, and I can let Opera fill it in for me.

The next two things are only supported in Internet Explorer, and I would by no use advice to implement them without thinking about it

I mean, I think it's no harm implementing them. It just gives a little more support to Internet Explorer users, but I wouldn't rely on them

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

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

Also (an IE only feature, I think...) is the support of vCards. You can add an attribute VCARD_NAME and it lets the browser fill in the appropriate vCard value. For example

<input type="text" name="email" VCARD_NAME="vCard.Email" />
like image 6
Timo Willemsen Avatar answered Oct 07 '22 21:10

Timo Willemsen