Extremely Simple In-textbox Help Text

by Dave on May 23rd, 2008

Cool script which displays ‘help text’ in a text box until it’s selected, then it disappears and allows the user to input text. It’s simple and just a few lines of javascript!

Javascript:
function clearText(field){
if (field.defaultValue == field.value) field.value = ”;
else if (field.value == ”) field.value = field.defaultValue;
}
Textbox input:
<input name=“s” type=“text” maxlength=“106″ id=“icePage_SearchBoxTop_qkw” class=“wsSearchBoxInputCommon wsSearchBoxInput” value=“Enter suburb name here, eg: hawthorn” onFocus=“clearText(this)” onBlur=“clearText(this)”/>

No comments yet

Leave a Reply

You must be logged in to post a comment.