Form Prefill Based on URL Parameters, Cookies, or Session Store | jquery.formprefill


Form prefill is a jQuery form caching plugin that saves all form field data in a browser cookie or session store and restores it as needed. For IE users, you may need to upload Promise polyfill into the document.

get url parameters javascript, jquery get all url parameters, get parameter from url, jquery get parameter

Built by more onion as a part of Campaignion.

How to make use of it:

1. Define the distinctive key values for every type of fields utilizing name and data-form-prefill-keys attributes as displayed under:

<input type="text" data-form-prefill-keys="input_name">
<input checked value="One" data-form-prefill-keys="checkbox_name another_name" type="checkbox">
<select multiple name="myform[personal_data][age]">
  <option value="1">one</option>
  <option value="2">two</option>
  <option value="3">three</option>

2. Or specify totally different key names for information write & read.

<input type="text" data-form-prefill-read="first_name firstname" data-form-prefill-write="first_name">

3. Put the jQuery library and the JavaScript file jquery.formprefill.js on the finish of the doc.

<script src="/path/to/cdn/jquery.min.js"></script>
<script src="/path/to/jquery.formprefill.js"></script>

4. Call the function on the HTML form to energetic the form caching plugin.


5. Clear the cached information:

// clear & reset values

// clear values
  resetFields: false

6. Available plugin choices with default values.

  prefix: 'formPrefill',
  storageKeys: function() {
    return {
      read: "key",
      write: "key"
  exclude: '[data-form-prefill-exclude]',
  include: '[data-form-prefill-include]',
  stringPrefix: 's',
  listPrefix: 'l',
  stores: [], // An array of custom store instances
  useSessionStore: true,
  useCookies: false,
  cookieDomain: ''

7. Read & write values.


var $formField = $('form').find('input[name=input_name]');
$'formPrefill').write({delete: true});

Browser Storage Based Form Caching Plugin, Form prefill Plugin/Github


See Demo And Download

Official Website(moreonion): Click Here

This superior jQuery/javascript plugin is developed by moreonion. For extra Advanced Usages, please go to the official website.