HTML input field hint

后端 未结 9 1455
轻奢々
轻奢々 2021-01-01 09:23

I want to provide the user with a hint on what he needs to enter into my text field. However, when I set the value, it does not disappear once a user clicks on the text fiel

相关标签:
9条回答
  • 2021-01-01 09:57

    With HTML5, you can now use the placeholder attribute like this:

    <form action="demo_form.asp">
      <input type="text" name="fname" placeholder="First name"><br>
      <input type="text" name="lname" placeholder="Last name"><br>
      <input type="submit" value="Submit">
    </form> 
    

    http://www.w3schools.com/tags/att_input_placeholder.asp

    0 讨论(0)
  • 2021-01-01 09:59

    This is exactly what you want

    $(document).tooltip({ selector: "[title]",
                                  placement: "top",
                                  trigger: "focus",
                                  animation: false}); 
    <form id="form">
        <label for="myinput1">Browser tooltip appears on hover but disappears on clicking the input field. But this one persists while user is typing within the field</label>
        <input id="myinput1" type="text" title="This tooltip persists" />
        <input id="myinput2" type="text" title="This one also" />
    </form>

    [ref]

    0 讨论(0)
  • 2021-01-01 10:01

    Define tooltip text

    <input type="text" id="firstname" name="firstname" tooltipText="Type in your firstname in this box"> 
    

    Initialize and configure the script

    <script type="text/javascript">
    var tooltipObj = new DHTMLgoodies_formTooltip();
    tooltipObj.setTooltipPosition('right');
    tooltipObj.setPageBgColor('#EEE');
    tooltipObj.setCloseMessage('Exit');
    tooltipObj.initFormFieldTooltip();
    </script> 
    
    0 讨论(0)
提交回复
热议问题