SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot Macchiato's Avatar
    Join Date
    Nov 2009
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make input text disappear?

    I have an input field in which you can type some text:

    HTML Code:
    <input type="text" id="text" value="Type some text here" maxlength="35" tabindex="10">
    I have some default text in this field, but I want to make the default text disappear when the user clicks on the default text or inside the input field.

    How can you do this?

  2. #2
    SitePoint Guru silver trophy JamesColin's Avatar
    Join Date
    May 2009
    Location
    Jomtien, Pattaya, Thailand
    Posts
    910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could try to add onclick="this.value='';" within your input tag, try it.
    Do you really need traffic? Where to? What for?
    If you really do need traffic then stop messing around!
    Advertise on my sites today: She Told Me & Best Reviewer :
    200,000+ UV / Month

  3. #3
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    A bit of javascript should do it:
    Code:
    <input type="text" value="Your email" onfocus="if (this.value == 'Your email') {this.value=''}" />
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,807
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    I originally thought about a simple line James but if the user then comes back and clicks the field again, whatever they have added gets wiped too.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Zealot Macchiato's Avatar
    Join Date
    Nov 2009
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works like a charm! Thanks for the help


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •