Show and hide text in a form field using onclick and onblur
A great way to reduce the need for a field heading/title is to include the informative text within the text field.
A great way to reduce the need for a field heading/title is to include the informative text within the text field. This is most commonly used in search fields, where there’s often no further available room to include a heading alongside or above.
So from having a black search field like this:

You can have one with some explanatory text contained. This will disappear as the user clicks in the box and should they not enter any text will reappear again when they click elsewhere on the page.

To recreate this version use the following code:
<input type=”text” value=”search the site…” onclick=”value=”” onblur=”if(this.value==”) this.value=’search the site…’;” name=”search” id=”search” />
You can then style your form field by using background images, removing the field border, adding an image instead of the standard submit button and make your very own lovely search field.
4 replies on “Show and hide text in a form field using onclick and onblur”
Leave a Reply
-
HTML email signature in Apple Mail
Step by step guide on how to add an HTML signature to Apple Mail.
-
Secure your WordPress Blog
A guide to securing your WordPress website.
-
Remove the shadow from Mac Screen Grabs
How to remove the shadow from Apple Screengrabs.
-
10 Useful Sites for Web Developers
Some useful websites for web developers.
-
3 FREE Apps to protect your PC
A few free apps to help you protect your PC.
-
Web Browsing Tips #1: Find in Page
Find copy in page in a web page.
-
Web Browsing Tips #2: Tabbed Windows
Using tabbed windows in your web browser.
-
Web Browsing Tips #3: Keyboard Shortcuts
Some web browsing keyboard shortcuts.
-
Redirect your site the Search Engine Friendly way
Using a 301 redirect is important when you change your website URL or web page URL.
-
Remove the WordPress Meta Tag from your Blog
Remove the WordPress meta tag from your WordPress site with this small function.
-
Stay secure, use more than one password
We need passwords for everything, but how can we stay secure and have multiple passwords without having to remember them all.
-
Forward your emails to one address
Find out how, using cPanel, you can forward your emails to one email address.
hello
hiii
Thanks for the support!
thank youÂ