Jump to Real's How-to Main page

Suggest a form value

When you click inside the text box, you will see that the text disappears.
<script language="Javascript">
<!--
function doClear(theText) {
  if (theText.value == theText.defaultValue) {
    theText.value = ""
    }
}
//-->
</script>
<form>
<input type="text" size=15 value="Try it here" onFocus="doClear(this)">
</form>

Or you can keep (and select) the default value :

<script language="Javascript">
<!--
function doSelect(theText) {
  if (theText.value == theText.defaultValue) {
    theText.select();
    }
}
//-->
</script>

<input type="text" value="Try it here" onfocus="doSelect(this)">

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]