How display text in password field

后端 未结 6 907
栀梦
栀梦 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:22

    There are several ways to do it but here is one way. I'm not saying that this is efficient but this will explain better of what is happening.

    Copy and paste this to try it out!

    
    
    
    

    It creates a text field with value of password and then when you click in it, it then changes to password field and removes its value. If you click and you did not enter anything then it will return to a text and change its value to password.

    You may also enter a text field along with less javascript code too, all you would need is the functions.

    If you want this to work in IE you would need to create two inputs, one for text and one for password and alternate display=none and display=block on each of them.

    element.style.display="none";
    

提交回复
热议问题