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=''"/> |
You can use:
1 2 | 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!
One Measly Opinion
John | Sep 13
I think you mean, “posterity”:)