Categories:

Home / Free JavaScripts / Forms / Here

Cut & Paste Remember Text field values

Credit: JavaScript Kit

Description: Certain form fields always contain the same values, such as your user's name, email address fields etc. This script will remember the values entered into these fields, and automatically fill out these fields the next time the user returns. It uses cookies to persist the values for 60 days (changeable). For "Contact Us" or "Tell a Friend" forms that are filled out repeatedly by a user, this can save them a lot of time!

This script can only remember the values of text fields (INPUT TYPE="text"), and not TEXTAREA, for example, since a cookie cannot store vast amounts of info.

Example: The first two fields' values will be remembered when you submit the form (try reloading the page afterwards).

Name:*

Email Address:*

Feedback:

Directions:

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

Step 2: With the script installed, simply modify your form with the parts in red:

<form onSubmit="rememberinput('yourname', 'youremail')">

Name:*<br /><input type="text" id="yourname" size="25" /><br />

Email Address:*<br /><input type="text" id="youremail" size="25" /><br />

Feedback:<br />
<textarea cols="25" rows="6"></textarea>

<br />
<input type="submit" value="Submit" />

</form>

where "yourname", "youremail" etc are the IDs of the form input fields that you wish to remember. Enter as many fields as you wish (separated by a comma), though as mentioned, only text fields are allowed.


JavaScript Tools:
Site Info

CopyRight 1998-2014 JavaScript Kit. NO PART may be reproduced without author's permission.