Pre-filled form input fields

« Back :: Tagged with Forms :: HTML :: JavaScript ::

This code snippet is usefull if you want to have a form field pre-filled with a text that explains what the field is for, and when the user sets focus on the field the text disappears.

Put the following code in the input tag and change the [TEXT] value to your liking.

 onfocus="if(this.value=='[TEXT]')this.value='';"
 onblur="if(this.value=='')this.value='[TEXT]';"

 

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <blockquote> <blockcode> <pre> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Copyright © 2010 deuxcode.com
Powered by Drupal. Valid XHTML 1.0 Strict and CSS 2.1.