【问题标题】:How does the browser decide which form fields are username/password? [closed]浏览器如何决定哪些表单字段是用户名/密码? [关闭]
【发布时间】:2010-12-04 03:19:49
【问题描述】:

现代浏览器保存密码。哪些标准会影响此决定?

背景:

我有一个注册页面,表格如下:

    <form action="/BlaBla/Account/Register" method="post">
    <div>
        <fieldset>
            <legend>Account Information</legend>
            <p>
                <label for="username">
                    Username:</label>
                <input id="username" name="username" type="text" value="" />
            </p>
            <p>
                <label for="email">
                    Email:</label>
                <input id="email" name="email" type="text" value="" />
            </p>
            <p>
                <label for="invitationCode">
                    Invitation Code:</label>
                <input id="invitationCode" name="invitationCode" type="text" value="" />
            </p>
            <p>
                <label for="securityQuestion">
                    Security question:</label>
                <input id="securityQuestion" name="securityQuestion" type="text" value="" />
            </p>
            <p>
                <label for="securityAnswer">
                    Security answer:</label>
                <input id="securityAnswer" name="securityAnswer" type="text" value="" />
            </p>
            <p>
                <label for="password">
                    Password:</label>
                <input id="password" name="password" type="password" />
            </p>
            <p>
                <label for="confirmPassword">
                    Confirm password:</label>
                <input id="confirmPassword" name="confirmPassword" type="password" />
            </p>
            <p class="buttons">
                <input type="submit" value="Register" />
            </p>
        </fieldset>
    </div>
    </form>

Mozilla 似乎认为 securityAnswerpassword 字段是用户/密码字段,结果很尴尬(存储为用户名的安全答案是错误的)。

【问题讨论】:

    标签: forms browser passwords


    【解决方案1】:

    输入类型设置为密码,所以...(例如&lt;input type="password" name="blah" /&gt;

    【讨论】:

      【解决方案2】:

      此外,如果您的表单中有超过 2 个字段,Internet Explorer 的“记住密码”功能不会记住您的密码。

      【讨论】:

      • 我听说过的关于 IE 的第一件事真的很聪明
      【解决方案3】:

      我猜它假设“密码”上方的字段是用户名。您可以尝试重新订购。

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-02
      • 2015-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-03
      相关资源
      最近更新 更多