This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// With the help of Jeremy Keith, I was able to create a fully scalable code sample that you can copy-paste into your project. | |
// It will save the user input value on blur, this includes radio buttons, checkboxes and date inputs besides regular text/number inputs. | |
// The only condition is that you give the form element on your page a data-attribute of data-form-topic="foo". | |
// This code snippet saves the data-attribute as the key to the localStorage, and the value of it will be an object with key/value pairs of the respective inputs name and value. | |
// Please refer to this gist somewhere in your code if you use it :) | |
// Happy coding! | |
// VARIABLE DECLARATIONS | |
// objects | |
let savedData = {}; |