Categories:

Home / Free JavaScripts / Forms / Here

Cut & Paste Clear default form value script

Credit: JavaScript Kit

Description: Use this script to automatically clear the default value of any form's input field when the mouse sets focus on it. Default input values are often used to aid in the explanation of the field's function or expected input, but become a nuisance once it's purpose has been served (namely, immediately after seeing it). This script intelligently distinguishes between default and user-entered text, and clears only the former on mouse focus.

Example: Click anywhere inside the input box!

Directions:

Step 1: Cut and paste the below script into the <head> section of your page:

Step 2: Inside the input box in question, add the below onFocus event handler to it, like below:

<form>
"
<input type="text" value="Search this site" onFocus="clearText(this)">
</form>

Repeat step 2, depending on the number of input boxes that you wish to have it's default value cleared on focus.


JavaScript Tools:
Site Info


CopyRight (c) 2018 JavaScript Kit. NO PART may be reproduced without author's permission. Contact Info