Thursday, October 1, 2009

adding watermarks in html textbox

Just copy and paste the following to your page

<
input type="text" class="hint" value="Search..."
onfocus="if (this.className=='hint') { this.className = ''; this.value = ''; }"
onblur="if (this.value == '') { this.className = 'hint';
this.value = 'Search...'; }
">

You can add and remove a special CSS class and modify the input value
onfocus/onblur with JS:


Then specify a hint class with the styling you want in your CSS for example:

input.hint {
color
: grey;
}

No comments:

Post a Comment