How To Control Text Inside Search Forms
Tony Williams | Feb 08, 2007 | Comments
Top Tip: Click here to run a free scan for common PC errors
I discovered a new site today that has a very similar to approach to www.onetipady.com. Daily Blog Tips does what it says on the tin. Everyday a useful tip is given for bloggers.
I found the site while I was looking for a solution to something on this site that has been bothering me. I wanted to customise my search entry forms so that text would be displayed giving helpful instructions to users, that would disappear when they clicked in the box, without them having to delete it.
Luckily Daniel has given some very clear instructions on how to do this.
First off you need to find the code that controls your searchform. It should look something like this:
< input name="s" id="s" size="20" type="text" />
Now you will need to add three new arguments inside that line:
* value=”Text to be displayed here”
* onfocus=”if(this.value==this.defaultValue)this.value=’’;”
* onblur=”if(this.value==’’)this.value=this.defaultValue;”
The last two arguments are the two magical ones that make sure that the text you inserted will disappear once the user clicks on the input area, and also that it will reappear if the user clicks somewhere else.
By adding these two lines of code to your search form you will get the desired result, and your final line of code will look like this:
< input type="text" name="s" id="s" value="Text to be displayed here" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>
Read Related Posts
Filed Under: Using The Internet
About the Author: Want to get more out of your PC, the internet or your mp3 player? Onetipaday.com is here to provide clear simple tips and guides to help you achieve just that. Each tip will be easy to implement and will take no more than 5 minutes to read and implement. What will you learn today?
- Daniel

