Auto Clear and Restore Form Element

Here’s another neat trick: making the search (or any field for that matter) have an auto clear and restore javascript element. This comes from Perishable Press.

<form action="" method="post">
<input value="Click here and this will disappear.." onfocus="if(this.value == 'Click here and this will disappear..') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Click here and this will disappear..';}" type="text" size="77" />

Just change the value “Click here and this will disappear..” to anything you want wherever it appears in the code.

Leave a Reply

Your email address will not be published. Required fields are marked *