【问题标题】:Disable autocomplete for password modification form禁用密码修改表单的自动完成
【发布时间】:2018-09-04 09:27:24
【问题描述】:

我听说现在所有的网络浏览器都会忽略autocomplete="off" 属性,因为它会阻止用户更改密码以便于记住(从而破解)。

但就我而言,我只想禁用更改密码表单的自动完成功能,而不是登录表单。我该怎么办?

这是我的(简化的)代码:

<!DOCTYPE html>
<html>
<body>
    <form action="?page=change_pass" method="POST">
        <input type="password" name="oldPass" placeholder="Current password">
        <input type="password" id="p1" name="newPass" placeholder="New password">
        <input type="password" id="p2" placeholder="Confirm new password">
        <button type="submit">Change password</button>
    </form>
    
    <script>
    //This script checks if p1 == p2
    </script>
</body>
</html>

感谢您的帮助。

【问题讨论】:

  • 你能发布你的代码吗?这对想要帮助的人会有所帮助
  • @ReyNorbertBesmonte 完成,时间抱歉
  • 根据我的经验,密码类型默认没有自动完成功能。
  • 顺便说一句,我很想知道像我一样将 GET 参数直接放在 action 属性中是否正确。
  • 如果您使用密码,切勿使用 GET。请参考此链接了解区别w3schools.com/tags/ref_httpmethods.asp

标签: html forms autocomplete


【解决方案1】:

试试:

<!DOCTYPE html>
<html>
<body>
    <form action="?page=change_pass" method="POST" autocomplete="off">
        <input type="password" name="oldPass" placeholder="Current password" autocomplete="off">
        <input type="password" id="p1" name="newPass" placeholder="New password" autocomplete="off">
        <input type="password" id="p2" placeholder="Confirm new password" autocomplete="off">
        <button type="submit">Change password</button>
    </form>
    
    <script>
    //This script checks if p1 == p2
    </script>
</body>
</html>

【讨论】:

    猜你喜欢
    • 2012-01-15
    • 2019-03-21
    • 1970-01-01
    • 1970-01-01
    • 2019-07-09
    • 2014-09-02
    • 2012-08-08
    • 2017-12-24
    • 2011-10-07
    相关资源
    最近更新 更多