input标签在谷歌浏览器记住密码下的一个自动填充BUG


Chrome自带记住密码功能,带来了极大方便

但是在点击保存之后,input标签会自动填充所保存的密码,如下图:

而且填充得很乱,密码不一定就会填充在密码框里。解决这一个BUG,可以用下面这个方案:

例如我们有个input标签:

1 <input type="text" class="test" id="test"> 

首先在这个input标签上面加一个display为none的input标签

1 <input type="text"style="display: none">  
2 <input type="text" class="test" id="test">

然后为input加一个autocomplete="off"的属性,此属性是 HTML5 的新属性,自动完成允许浏览器预测对字段的输入,但是只只用于text, search, url, telephone, email, password, datepickers, range 以及 color类型的<input>和<form>,所以如果我们需要一个密码框,需要给input设置一个onfocus="this.type='password'" 

1 <input type="text" class="test" id="test" style="display: none";>  
2 <input type="text" class="test" id="test" placeholder="请输入密码" autocomplete="off" onfocus="this.type='password'">  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM