Disappearing Default Form Text

 

Disappearing Default Form Text

When using forms within your web site, there may be times when you will want to include an example of what you’d like your visitors to fill in your form field. Although you could place some default text within your form field, your users would need to delete the default text in order to type in their own information.

However, this cool little JavaScript code will enable you to display some example default text within a text box that will disappear when clicked on – much better than your users having to delete the example text.

 

Example:




Place your cursor inside the text box to see the text disappear.

Place your form code within your HTML like this:

<FORM action="http://www.domain.com" method="post">
<INPUT type="text" size="25" value="Enter Your Default Text Here" onFocus="if(this.value == ‘Enter Your Default Text Here‘) {this.value = ”;}" onBlur="if (this.value == ”) {this.value = ‘Enter Your Default Text Here‘;}" />
<INPUT type=submit value=Submit>
</FORM>

Change the default text displayed within your text box by editing the code indicated in bold.

This concludes the Disappearing Default Form Text code.

 
 

 
 
Visit the following pages for a wealth of copy and paste codes and tips:

HTML Tips
Copy and paste special effect HTML codes for your web page.

HTML Codes
An HTML codes chart you can use to copy and paste codes into your web page.

HTML Color Codes
An HTML color codes chart you can use to copy and paste color codes into your web page.

JavaScript Codes
Copy and paste special effect JavaScript codes for your web page.

Web Design Tips
Tips, tricks, and special effect codes for your web page.

HTML Tags
A list of HTML tags.

HTML 5 Tags
A list of the latest HTML tags to be developed.

ASCII Codes
Special text characters and code for your web page.