html解決input type=「password」タブ自動記憶アカウントパスワード
8993 ワード
, input type="password" type="text"
input , input , , input ,
ps: , ●● ●●●● 。
/span>html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Titletitle>
<script>
window.onload = function () {
document.getElementById("password").addEventListener('input', function () {
var _this = this;
var newPassword = _this.value;
var oldPassword = _this.getAttribute("password");
var deta = newPassword.length-oldPassword.length;
var truePassword = "";
var p = _this.selectionEnd;//
for(var i=0; i<newPassword.length; i++){
var c = newPassword.charAt(i);
if(i<p && c!='●'){
truePassword += c;
}else if(i<p && c=='●'){
truePassword += oldPassword.charAt(i);
}else {
truePassword += oldPassword.substr(oldPassword.length-newPassword.length+p,newPassword.length-p);
break;
}
}
newPassword = truePassword.replace(/\S/g, '●');
_this.setAttribute('password', truePassword);
_this.value = newPassword;
// win8 input
_this.selectionEnd = p;
_this.selectionStart = p;
//console.log(truePassword);
},false);
}
script>
head>
<body>
<input id="password" type="text" placeholder=" " password="" >
body>
html>
:
jQuery input :
$(selector).on('input', function () {
});
js input value , 。
, !