views:

63

answers:

2

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.

+2  A: 

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
+2  A: 

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