save restore data - Free Download Get And Restore Form Data Using Local Storage - jQuery Save My Form

Free Download Get And Restore Form Data Using Local Storage – jQuery Save My Form

Posted on

This time I will share jQuery Plugin and tutorial about Get And Restore Form Data Using Local Storage – jQuery Save My Form, hope it will help you in programming stack.

save restore data - Free Download Get And Restore Form Data Using Local Storage - jQuery Save My Form
File Size: 31.3 KB
Views Total: 1316
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Just another jQuery plugin to prevent losing data that automatically saves form values in local storage when editing HTML forms.

The plugin will automatically fill the corresponding form fields from the data saved in the local storage on page refresh or on the next visit.

Optionally, you can set the plugin to automatically clear the save data from the local storage when the form is successfully submitted.

Supports any form fields such as input, textarea, checkbox, select, radio button, etc. Also supports HTML5 input types like range slider, date input, color picker and much more.

How to use it:

1. Download & unzip the plugin and load the minified version of the Save My Form plugin after jQuery.

1 <script src="/path/to/cdn/jquery.min.js"></script>
2 <script src="/path/to/saveMyForm.jquery.min.js"></script>

2. Attach the function saveMyForm to your HTML form and done.

1 $(function () {
2   $("form").saveMyForm();
3 });

3. Define form fields you want to ignore. By default the plugin will automatically ignore sensitive fields like password fields, hidden input, file selector, etc.

1 $(function () {
2   $("form").saveMyForm({
3     exclude: ':password, input[type="hidden"], :file, .disable_save'
4   });
5 });

4. Determine whether or not to reset the form on submit. Default: true.

1 $(function () {
2   $("form").saveMyForm({
3     resetOnSubmit: true
4   });
5 });

5. The plugin also works with form fields with the same name attribute.

1 $(function () {
2   $("form").saveMyForm({
3     sameNameSeparator: '___'
4   });
5 });

6. Determine whether or not to restore input data on page reload. Default: true.

1 $(function () {
2   $("form").saveMyForm({
3     loadInputs: true
4   });
5 });

7. More configuration options with default values.

01 $(function () {
02   $("form").saveMyForm({
03  
04     // include these form fields
05     include: null,
06  
07     // used for data when saving the values
08     formName: undefined,
09  
10     // add the page path to the name of the form
11     addPathToName: false,
12  
13     //  the length of the path
14     addPathLength: -255
15      
16   });
17 });

8. Clear the data manually.

1 $("form").saveMyForm('clearStorage');
2 // or
3 $.saveMyForm.clearStorage('FormName');
4 // or
5 $.saveMyForm.clearStorage(PathName + '_' + 'FormName');

9. Callback functions.

1 $.saveMyForm.addCallback({
2   match:function(element){
3     // do something
4   },
5   loadElement: function(element, plugin){
6     // do something
7   }
8 });

Changelog:

2020-05-14

  • v1.5.6

This awesome jQuery plugin is developed by pjjonesnz. For more Advanced Usages, please check the demo page or visit the official website.