textarea onclick remove text

user780483 picture user780483 · Jun 15, 2011 · Viewed 36k times · Source

I know how to remove text in a simple html textbox but html textareas seem much more complicated. instead of the value attribute you put the text right between:

 <html>
<textarea> </textarea>.  
</html>

This is why im having trouble making an onFocus and onBlur event.

Answer

Rafael Ernica picture Rafael Ernica · Jul 14, 2011
<textarea name="message" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;">
Put anything for default value here
</textarea>

Live example: http://jsfiddle.net/SRYLg/