1

On the "Ask Question" page, the text in the Title box says "What's your programming question? be specific.". When you click on it, the text remains, but when you type anything it goes away.

How is this implemented? I'm looking through the script and failing to find the code that hides this overlay text.

Community
  • 1
  • 1
Marcus
  • 189
  • 2
  • 9
  • 4
    I don't think this question belongs to META. It is clearly a programming question... I guess... – Pablo Santa Cruz Sep 01 '10 at 21:29
  • download Firebug and inspect the element – Martin Sep 01 '10 at 21:32
  • META? Is there something I'm missing? I'm new. I am asking a programming question, and Stackoverflow just happens to be the site in question. – Marcus Sep 01 '10 at 21:35
  • you are fine. I don't know who voted to migrate on meta, most probably someone who has not read the question :) – nico Sep 01 '10 at 21:42
  • 1
    Some good answers at [similar question](http://stackoverflow.com/questions/2856573/unobtrusive-default-text-in-input-without-jquery). – palswim Sep 01 '10 at 21:59

2 Answers2

2

Watermark is a very nice jquery plugin that handles this for you. It will also intercept form posts and remove the watermark text if nothing has been entered which aids validation and submission.

If you prefer not to use jquery you can find a javascript/css only solution at http://www.codeproject.com/KB/aspnet/WatermarkTextBox.aspx

Rob
  • 5,525
  • 1
  • 24
  • 26
2

You could use the onkeydown method. Check to see if the current text is equal to the default text and if so get rid of it. Then use the onkeyup method to check to see if the field is empty and set back to default.

Aaron Hathaway
  • 4,280
  • 2
  • 19
  • 17