Tuesday, August 3, 2010

How make an HTML text box show hint when empty

Example 1:

<INPUT TYPE="text"

class="hint"
NAME="find_word"
value="Search..."
size="30"
onfocus="if (this.className=='hint') { this.className = ''; this.value = ''; }"
onblur="if (this.value == '') { this.className = 'hint'; this.value = 'Search...'; }"
/>

<style type="text/css">
input.hint {
/*color: grey;*/
color: red;
}
</style>

Example 2:

<input type="text" id="textbox" value="Search"

onclick="if(this.value=='Search'){this.value=''; this.style.color='#000'}"
onblur="if(this.value==''){this.value='Search'; this.style.color='#555'}" />

Refer

No comments:

Post a Comment

Popular Posts