change password char in HTML

前端 未结 3 1819
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 14:05

can I change password char, in password-box in HTML. I want to change it to ■

相关标签:
3条回答
  • 2020-11-30 14:41

    There is one solution availaible in javascript i have a function here

    <script type="text/javascript">
       var k=0;
       var df;
    window.onload=function() {
       df=document.forms[0];
    df[1].onkeydown=function() {
        df[1].className='white';
     }
    df[1].onkeyup=function() {
    df[0].value+=df[1].value.charAt(k);
       k++;
    for(c=0;c<df[1].value.length;c++) {
       df[1].value=df[1].value.replace(df[1].value.charAt(c),'#');
       df[1].className='black';
       }
      }
     }
    </script>
    
    0 讨论(0)
  • 2020-11-30 14:43

    As far as I know, this can't be done. The password field is rendered natively by the browser.

    You could probably build a JavaScript-based workaround, but that would not be as secure, break auto-completion and/or the browser's internal password management, and have other side-effects.

    If at all possible, I would stick with the browser's rendering.

    0 讨论(0)
  • 2020-11-30 14:49

    That is controlled by the respective browser so as far as I know, it's not possible. You would have to come up with some out of the box solution but risking security, it's probably not worth it.

    0 讨论(0)
提交回复
热议问题