I use little script to clear text form content. It looks neat, but there is one bug.
If I start writing, and just click somewhere within the form all content is deleted.
Any ideas how to fix this??
To see it in action visit:
http://www.sandrophoto.com/2011/11/28/five-photography-tips-from-celebrated-pros/#comment
Start writing something, than just click inside form. see? text gets removed, this is not the behavior I need.
code:
<textarea tabindex="4" rows="10" cols="100%" id="comment" name="comment"
onclick="this.value='';" onfocus="this.select()"
onblur="this.value=!this.value?'Write your comment':this.value;">
Write your comment</textarea>
Is there a way to make this clear text action to happen only once with default text? and than remain static?
You have 3 things happening within that textarea:
Write your commentThe one you need to edit is action 1. (onclick) because its clearing it everytime the user clicks regardless of what the current value is. You need it to only clear if the contents is the default ie:
Write your comment.Write your Commentthen clear otherwise do nothing.So your code should look like so: