Everyone hates when something happens to that huge web form they were filling. Accidentally closed a browser window? Pressed a Back button? Computer crashed? “Arrgghh, have to fill the form again!” — says your user… or just leaves your website. If you don’t want this to happen, Garlic.js is here to help you!
What is Garlic.js
Garlic.js will automatically persist forms in user’s browser until the form is submitted. The data is stored in localStorage, so it survives browser restarts. It is removed from local storage once a user submits the form.
How to use Garlic.js to persist forms
Garlic requires jQuery, so include it along with
garlic.js to your page. Add
data-persist="garlic" attribute to your
<form data-persist="garlic" method="POST">
and done! Now Garlic.js will do its job: it will automatically save everything your visitors enter to or selects within this form into their browser’s local storage, and then clean it once they submit the form. You can also tell Garlic to not clear the storage by adding