禁用密码修改表单的自动完成功能

时间:2018-03-26 09:24:03

标签: html forms autocomplete

我听说现在所有网络浏览器都会忽略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>
&#13;
&#13;
&#13;

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

试试:

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