Oliver Nassar

Form Data Cacher (JavaScript Class)

June 01, 2022

While building my Mass Image Generator experiment (inspired by a need I had over at Iconduck), I kept losing the state of my form inputs.

It was particularly frustrating, because the form input values needed to be formatted precisely.

From that, Form Data Cacher was born.

Right now, it's still very much a proof of concept (it only works with <textarea /> and some <input /> tags), but it's proved useful. Therefore, I wanted to open source it.

It works by storing some form values in a client's localStorage, and recalling them when the page subsequently loads.

Usage is straight forward: apply a specific class name to the desired HTMLFormElements, and it'll kick right in.

It's been open sourced, and is available on GitHub.


Example


Implementation Code

FormDataCacher.init();

Todo


References