How display text in password field

后端 未结 6 906
栀梦
栀梦 2021-02-06 11:50

I have the password field on page. I want to display text \"Enter password\" on screen before entering password but on focus when user enter password it should go back to passwo

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-06 12:29

    You can either give it an image background with the text Enter Password that you change dynamically using javascript (ideally by just removing a CSS class),

     or
    
    

    or place a fake input that you replace with javascript for a password input.

    I'm not sure how well it would cross browser to change the type of input on the fly.

    document.getElementsByTagName("input")[0].type = "text" /* change a hidden field to text*/ works on Firefox, but I wouldn't rely on it working well on IE without testing.

提交回复
热议问题