This jQuery html 5 plugin automatically saves and persists form state on the client-side across page requests without need of server-side state management or cookies. ALL the major browsers support this!
code snippit
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.min.js"></script>
<script src="http://s3.amazonaws.com/jasonsebring/js/json2.js"></script>
<script src="http://s3.amazonaws.com/jasonsebring/js/dumbFormState-1.js"></script>
<script>
jQuery(function(){ // ensure dom is loaded first
jQuery('form').dumbFormState();
});
</script>
Its best to save your own files locally as the file hosting is subject to change without notice.
features
* keeps the state of form entries in browser session or across sessions without cookies
* able to choose form entries not to persist
* works across multiple forms and pages
* automatically persists form data without submit
* can remove persisted data in a form, a session, local or all
* plays nicely with your form events
* fails gracefully on unsupported devices
dependancies:
* HTML 5 storage capability Safari 4+, Opera 2.7+, IE 8+, Firefox 3.5+, Chrome 4+
* jQuery 1.5 : tested only in latest version -> jQuery.com
* json2.js : Douglas Crockford GitHUB -> https://github.com/douglascrockford/JSON-jsconfigurable options:jQuery('form').dumbFormState({
persistPasswords : false, // default is false, recommended to NOT save people's passwords
persistLocal : false, // default is false, setting to false will enable sessionStorage, setting true will span across sessions
skipSelector : null, // takes jQuery selector of form entry items you DO NOT want to persist such as '#password,#creditcard,#cvv2'
autoPersist : true // default is true, if false will only persist on form submit
});instance methods:jQuery('form').dumbFormState('remove'); // removes data and events associated with forms matching the selectorstatic methods:jQuery.fn.dumbFormState.removeSession(); // clears all session data relating to dumbFormState
jQuery.fn.dumbFormState.removeLocal(); // clears all local data relating to dumbFormState (across sessions)
jQuery.fn.dumbFormState.removeAll(); // clears all data relating to dumbFormState
special note:
This only persists form elements that have a "name" attribute. Take care to clean up the data after the user does not need it.
demo:
multiple <form> tags shown below with the same names, persists for browser session, does NOT store passwords by default.
The form looks odd in IE9 due to IE9's inability to style markup to standard, however it the script functions as designed in IE9.
This page demonstrates offline storage capabilities for HTML 5 persisting form data on the client-side. The potential of HTML 5 is a game changer. Imagine all the server-side code written to maintain postbacks and form state in general which is not needed anymore.
Contact for bugs, etc.