取消表单的密码提示

版权声明:转载原创文章请注明:文章转载自:前端精髓 https://blog.csdn.net/wu_xianqiang/article/details/80713924

我们都知道浏览器有记住密码的功能, 只有当你在某个网站中输入用户名和密码,就会弹出如下提示框
logo

现在选择点击保存,当你下次再登入这个网址的时候,表单下面会有密码提示,效果如下
logo

表单的密码提示经常会泄露用户的个人信息,所有前端需要禁止密码提示,防止表单自动填充

 <form action="?" method="post">
      <input type="text" style="display: none;">
      <input type="password" class="form-control"  placeholder=""  autocomplete="new-password">
      <input type="submit" value="提交">
  </form>

代码有两个需要注意的地方,第一个是需要在表单前面加个隐藏表单 <input type="text" style="display: none;">,第二个是表单要设置 autocomplete="new-password" 属性。

有什么不懂的地方可以在GitHub中给我提问,点这里:连接

猜你喜欢

转载自blog.csdn.net/wu_xianqiang/article/details/80713924