Forum Moderators: open
My site has a js search form. I'd like for that form to already have text in it. The end user should be able to search using that pre-defined string, or change the text to something else to search for.
Thanks In Advance,
Chris Leonard
<input name="name" type="text" class="textbox" OnBlur="if (this.value=='') this.value='Please enter your name'" value="Please enter your name" size="35" OnActivate="if (this.value=='Please enter your name') this.value='';">
This will bring show a form field with "Please enter your name" as the value. If you click on the field, the text vanishes - if you leave the field without typing anything, "Please enter your name" reappears.
Non JS browsers should see naught.
<input type="text" name="q" value="Enter Search Here">
To which you can add
<input type="text" name="q" value="Enter Search Here" onFocus="this.value='';">
If it bothers you that this blanks it while tabbing, use onClick
<input type="text" name="q" value="Enter Search Here" onClick="this.value='';">