码迷,mamicode.com
首页 > Web开发 > 详细

html页面禁止自动填充浏览器记住的密码

时间:2016-11-05 14:37:09      阅读:346      评论:0      收藏:0      [点我收藏+]

标签:com   function   dmi   pwd   ext   length   att   就会   rom   

现在的浏览器功能越来越强大,比如Chrome浏览器,在一个系统login的时候我们一般会记住密码,那么在整个系统中,浏览器一旦遇到 type="password"的控件,就会把密码自动填充到该控件。非常烦恼,问了一下同事有人说可以用autocomplete="off" 来禁用自动填充, 经过简单的实践没有达到我的需求。于是回到最原始的解决方案。
比如html如下

<input type="password"  name="admin_pwd" minlength="6" required="true" />

在页面初始化的时候 把type改为text 并且清空,在focus事件触发的时候又把type改为password。
 $("input[name=‘admin_pwd‘]").attr("type", "text").val("").on("focus", function () {
            $(this).attr("type", "password");
        });

当页面ajax提交后又把type改为text且清空该值
  $("input[name=‘admin_pwd‘]").attr("type", "text").val("");

html页面禁止自动填充浏览器记住的密码

标签:com   function   dmi   pwd   ext   length   att   就会   rom   

原文地址:http://www.cnblogs.com/majiang/p/6032776.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!