Save Form Values To Local Storage – form-saver

Category: Form , Javascript | January 29, 2020
Author: kieranbarker
Views Total: 114
Official Page: Go to website
Last Update: January 29, 2020
License: MIT

Preview:

Save Form Values To Local Storage – form-saver

Description:

Yet another scrip to prevent losing form data that automatically stores the current form field’s values as a JSON object in local storage.

How It Works:

  • Save form values when input event fires
  • Clear saved values when a user submits the form
  • Populate the form with existing values on page refresh

How to use it:

1. To use the script, you must assign a unique name to each form field.

<form>
  <div>
    <label for="name">Name</label>
    <input id="name" type="text" name="name">
  </div>
  <div>
    <label for="address">Address</label>
    <input id="address" type="text" name="address">
  </div>
  <div>
    <label for="email">Email</label>
    <input id="email" type="email" name="email">
  </div>
  <div>
    <button type="submit">Submit</button>
  </div>
</form>

2. Download and load the script at the end of the document. That’s it.

<script src="js/app.min.js"></script>

You Might Be Interested In:


Leave a Reply