先搞懂原理
原理很简单,浏览器记住密码后只要识别到一个type为text后又紧接着一个password
时默认填充之前浏览器记住的账号密码。
解决方案
1.把input type=”password” 改成 input type=”text” 并在后面加上 οnfοcus=”this.type=’password’”,
2.在文档加载完成后将密码输入框设置为空:
window.load = function(){
document.getElementById(‘密码域ID’).value=’’;
};
3.在用户名和密码之间加上一个隐藏的文本框:
.hidden{
height:0;
width: 0;
border-width: 0px !important;
}
<input type="text" name="name" autocomplete="off">
<input type="text" class="hidden">
<input type="password" class="hidden">
<input type="password" name="pwd" autocomplete="off">