Today I'm working on a new version of an existing form, where the original developer had added "hints" in to TextArea elements on the form.
<textarea name="details" onfocus="this.value='';"> Please put something about yourself in here </textarea>
Anybody spot the obvious and massive usability issue with this approach?
Here's an example of one in use:
What if you start writing in it, then move to the next textarea and then come back to this one to make a change. Yep - you lose everything you previously entered. DOH!
Not to mention that you need to validate the field not just for whether it's empty but also for whether it contains just the hint - suggesting the user didn't enter anything at all, even though there's text in there.
I'll be taking the hints out of the fields, but, if I were keeping them, there's a simple way to correct this bug:
<textarea name="details" onfocus="this.value=((this.value==this.defaultValue)?'':this.value)"> Please put something about yourself in here </textarea>
An example of fixed version in use: