Reputation: 151
Basically, when I tab through this form, for every input field the text is highlighted, but this doesn't happen for my textareas. Any help or ideas would be appreciated. I've included my textarea html below just in case.
<textarea onblur="if(this.value==''){this.value='Embed Code'}" onclick="if(this.value=='Embed Code'){this.value=''}" name="post.code">Embed Code</textarea>
Upvotes: 1
Views: 2747
Reputation: 147413
Use onfocus instead of onclick, as getting focus from tabbing does not dispatch a click event (so the onclick handler isn't called). Note that HTML5 has the placeholder attribute that will do what your script is doing.
To select the text in the textarea, add a handler for the focus event:
<textarea ... onfocus="this.select()" ...
Note that this may annoy users as they don't expect this to happen for textarea elements.
Upvotes: 2