search

Home  >  Q&A  >  body text

javascript - How can I display text instead of dots by default before the password is entered on the registration page?

<input type="password" name="info[password]" id="password3" class="list-input" onblur="if(this.value==''){this.value=' Please enter a 6-20 digit password';}" onfocus="if(this.value=='Please enter a 6-20 digit password'){this.value='';}" value="Please enter a 6-20 digit password Password" placeholder="Please enter 6-20 digit password"/>

This sentence is now displayed by default..., and "Please enter a 6-20-digit password" is displayed after the mouse is clicked on the input box. How can I make it display "Please enter a 6-20-digit password" by default, and after input it becomes...

学习ing学习ing2774 days ago779

reply all(8)I'll reply

  • PHP中文网

    PHP中文网2017-06-22 11:55:46

    You wrote a lot of messy attributes, but you didn’t write placeholder. . .
    placeholder="Please enter 6-20 digit password", add this to the input

    reply
    0
  • 大家讲道理

    大家讲道理2017-06-22 11:55:46

    Of course, if you use js to assign a value to vulue, it will be displayed as *. You can try adding placeholder to the input tag

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-22 11:55:46

    New browsers support placeholder, and then set the css attribute to make the text gray so that it is not too dark.

    reply
    0
  • typecho

    typecho2017-06-22 11:55:46

    Use placeholder

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-06-22 11:55:46

    If you don’t need to consider compatibility issues under IE, then the easiest way is placeholder
    But the placeholder attribute is compatible up to IE10
    So if you need to consider compatibility with browsers below IE10, I suggest you take a look at a plug-in jquery-placeholder

    reply
    0
  • 滿天的星座

    滿天的星座2017-06-22 11:55:46

    <input type=""  placeholder="默认文字">

    The mobile terminal is compatible. If it is PC terminal, you can download the plug-in compatible with ie8-
    Download address:
    Link description

    reply
    0
  • 三叔

    三叔2017-06-22 11:55:46

    <input type="password" placeholder="The default text you want to display">

    reply
    0
  • 代言

    代言2017-06-22 11:55:46

    The simplest is placeholder, but this is not compatible with IE.
    The way to achieve compatibility is to
    write an em tag (the position is the sibling node of the input). The position is absolutely positioned to the input position of the input box.
    Use JS to determine whether the control has focus. / blur/ keyin status to confirm whether the em tag is displayed

    reply
    0
  • Cancelreply