1
surgiie
8y

Any recommendations on a jquery/js plugin that saves form fields in the scenario where the user left the form or page they can come back and still have the values from when they left. I wrote up some thing for a small form on an old site using sessionStorage api but I need something that can work with any form or perhaps multiple forms at once. any good plugins out there?

Comments
  • 3
    Just use localStorage
  • 2
    you can save the value of the field in a cookie. then populate the fields value if there is a value for that specific field in the cookie.
  • 2
    I second localStorage. Straightforward and no plugins necessary. MDN has solid documentation.
  • 1
    @noonesboy @champion01 i wrote something once for a small form on an old site that used sessionStorage. I wrote this in a quick pinch with not worrying about if it was best or most effecient way to do it. Now that i have more free time id like to go back and change/optimize it because im a bit sure that this is sloppy and likely to not function with other libraries. That being said, heres the code:

    https://gist.github.com/surgiie/...
  • 1
    @surgiie I'm on my phone but the code looks good.

    I typically work in angular, and for this I would make a directive.
  • 1
    @champion01 https://github.com/surgiie/...

    I made some enhancements. Devs can define either session or local storage via custom data atttribute.
Add Comment