I have an input field with some pre defined text explaining what it is for. If the user clicks it should get blank so the user can write his/her own. But this should not happen if the user already entered custom text and for some reason clicks the field again.
The first part works, the second doesn't. How do I need to adjust this code?
<input type="text" value="Write something..." firstclick=true
onclick="if(this.getAttribute('firstclick')) {
this.value='';this.setAttribute('firstclick',false);} ;"/>
this.firstclick?placeholderattribute, which takes care of it automagically. In compatible browsers, that is. For other browsers, see Jamiec's comment