Save Form Values To Local Storage – form-saver

Category: Form , Javascript | January 29, 2020
Views Total:272 views
Official Page:Go to website
Last Update:January 29, 2020


Save Form Values To Local Storage – form-saver


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.

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

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