html input密码显示为*号


<!DOCTYPE html>  
<html encoding="utf-8">  
<head>  
    <style>  
    *{margin:0;padding:0}  
    input{font:14px Monospace;height:20px;width:160px;}  
    label{display:inline-block;width:100px;height:20px;}  
    #pass{position:absolute;left:100px;top:0;opacity:0;filter:alpha(opacity=0);z-index:2;}  
    form{position:relative;}  
    #hint_pass{position:absolute;left:100px;}  
    </style>  
</head>  
<body>  
    <form>  
        <label>Password:</label>  
        <input type="text" id="hint_pass" maxlength="20" tabindex="-1" />  
        <input type="text" id="pass" name="pass" maxlength="20" />  
    </form>     
<script>  
    var pass=document.getElementById('pass');  
    var hint_pass=document.getElementById('hint_pass');  
    pass.onkeyup=pass.onchange=function(){hint_pass.value=pass.value.replace(/./g,'*');};  
</script>   
</body>  
</html>  

 


免责声明!

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



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