Clear Text on Input

Discussion in 'HTML & Website Design' started by sunst4r, Jun 12, 2008.

  1. #1
    Hi,

    I'm looking to create a custom search field with a text input that clears the default text when the user clicks into the field.

    Anyone have the code to make it clear the text?

    thanks

    Sunst4r
     
    sunst4r, Jun 12, 2008 IP
  2. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You'll want to use Javascript to put the text in and then remove it when the user puts focus on the input.

    This might be better than having the text as a default value of the input which the non-javascripted user has to manually delete before filling it in.

    Try Javascript forums.
     
    Stomme poes, Jun 12, 2008 IP
  3. sunst4r

    sunst4r Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'll check some more out, sort of on the right track but having some issues with the ones from other forums. Just wondered if anyone had some code already that i could use.

    cheers

    Sunst4r
     
    sunst4r, Jun 12, 2008 IP
  4. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    805
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    158
    #4
    Try JavaScript similar to this:
    
       form.gsearch.select()
       form.gsearch.value=""
    
    Code (markup):
    Where gsearch is the input text name value. Don't forget to issue the callback on focus.

    Q...
     
    QiSoftware, Jun 12, 2008 IP