5

使用 firefox 查看网站时,我在网站上输入密码时遇到问题,这里是 html:

<div class="passField">
    <label for="password">Password : </label>
    <input type="password"
        name="password" id="password" 
        title="6 to 20 characters, one uppercase and numbers allowed." placeholder="APassword123"
        maxlength="20" pattern="^[A-Za-z0-9]{6,20}$"
    />
    <span class="inputDesc">'.$passwordDesc.'</span>
</div>

通过电子邮件中的链接将用户定向到包含此输入的页面,如下所示:

http://www.mysite.com/reset.php?theId=1&theKey=699acfc121edfd91df48d5d99044d74d

执行数据库检查,如果详细信息与我的数据库中与该用户 ID 相关的详细信息匹配,则向用户显示两个输入。一个用于初始密码,一个用于确认输入的密码。

我遇到的问题是,当页面加载时,初始密码输入包含几个点(数据),而第二个输入包含占位符......两者都是密码类型。

这是一个屏幕截图,看看我在说什么:

怪癖 1

这是 IE 中的同一页面:

怪癖 2

据我了解,它们都应该统一显示,无论输入类型如何,都像往常一样显示占位符,并且由于我没有为此输入分配任何值,为什么在没有分配值时以这种方式呈现一个值甚至根据页面来源?

任何与此相关的帮助、理解或信息将不胜感激,谢谢!

4

1 回答 1

6

Use autocomplete="off" on the fields to avoid pre-filling of the fields. Of course this does not account for possible JavaScript or anything else populating the field.

Edit - Further explanation (because it was asked for)

Most browsers have a built in function to automatically fill form fields. They fill in fields that have standard names a user has filled in often(this is often asked first) For example address fields are often filled like this.

2nd part of the feature is filling saved passwords, but browsers are not really smart. When you save a password on, for example, http://example.com/phpmyadmin they will also fill in a password field on the homepage of http://example.com/ Which is often incorrect because the login on the homepage is pretty sure not the login for the admin area.

You can solve this issue by either setting autocomplete=off which turns this feature off for the input field(could be that this also works on entire forms if you want) or giving the fields different names. Whereas using autocomplete=off is far more reliable.

于 2012-09-18T09:07:33.797 回答