19 Jul 2006

This is actually quite an easy task but when I need to do it, I often forget what the code is, so I’m putting it here for posterity.

  1. <input type="text" name="text_field" size=50 value="Fill in this text field! " onClick="this.value=''"/>

Stu Hall adds:

You can use:

  1. onfocus="if(this.value=='Fill in this text field!')this.value='';" onblur="if(this.value=='')this.value='Fill in this text field!';"

…to put the text back in when you click out of it as well rather than leaving it blank. Just another one for posterity!

1 Comment

  1. No. 1 John 09/13/07

    I think you mean, “posterity”:)

Tell Me What You Think

About Me

My name’s Jen; I’m a cynical, sarcastic, ex-drummer who is fond of dark humor. I've held way too many factory & retail jobs but finally found my calling one Christmas holiday in a dark, musty basement. I am now a CSS & XHTML web standards looney and can be found daily—when I’m not at my Mac—at the local fair-trade coffee shop buying an iced-soy mocha no matter the temperature.

I am also the owner of Pop Stalin Design specializing in CSS & XHTML web design as well as custom WordPress themes.