HTML登录表单:提供用户名,自动填充密码 [英] HTML login form : provide username,autofill password

查看:124
本文介绍了HTML登录表单:提供用户名,自动填充密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个登录表单,我只需要提供用户名,因为它会记住我的密码并自动填写密码字段(例如,像gmail auth中一样).

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

我该如何实现?

谢谢

路卡

推荐答案

这种类型的行为通常由浏览器定义.但是,您可以采取一些措施来改善这种行为.

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" />

使用这些名称确实可以有所作为.例如,我使用Opera浏览器,在设置中,我设置了一些值.例如名称",地址",电话号码".歌剧将查找具有相同名称的字段,我可以让Opera替我填写.

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.

接下来的两件事仅在Internet Explorer中受支持,如果不考虑的话,我将不使用任何建议来实现它们

我的意思是,我认为实施它们无害.它只是为Internet Explorer用户提供了更多支持,但我不会依赖他们

Internet Explorer还支持称为autocomplete的属性,您可以控制IO是否应自动完成input.您可以按以下方式使用它

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

vCard的支持也是(我认为是IE独有的功能).您可以添加属性VCARD_NAME,它可以让浏览器填写适当的vCard值.例如

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" />

这篇关于HTML登录表单:提供用户名,自动填充密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆