JavaScript remove search text…

I have found this script comes in very handy from time to time and i cant seem to find it on the Internet. So here it is.


<input type="text" value="search" onclick="if (this.value == 'search') { this.value = '' }">


This will allow you to have an example in each text box to help the user better understand your form. Instead of the user having to manually delete all the text inside, it will simply remove itself at a click of a button AND it will only remove the text you ask it to so it wont end up deleting all of the text your user input into the textbox.

How it works…

if (this.value == 'search')


this.value = ''


JavaScript remove search text…