<input ID="_PSD"></input> <script> function passwordText(ID,pd,mark){ mark=mark||"*" var PSD=document.getElementById(ID) var password=pd var lh=PSD.value.length setInterval(function(){ if(PSD.value.length!=lh){ if(PSD.value.length>lh)run(1) else run(0) lh=PSD.value.length } },1) function run(n){ switch(n){ case 0: password.length-=1 break case 1: password.push(PSD.value.charAt(PSD.value.length-1)) break } PSD.value="" for(var i=0;i<password.length-1;i++) PSD.value+=mark if(password.length) PSD.value+=password[password.length-1] } } var password=[] passwordText("_PSD",password,"*") </script>
时间: 2024-10-09 22:54:09