If your form only contains text inputs (not as arrays), you may try this plugin, which I've adapted from its unserialize function counterpart (https://gist.github.com/rcmachado/242617#file-jquery-unserialize-js), but instead of returning an object, it fills the form it applies to.
(function($){
$.fn.fillformwithserialized = function(serializedString) {
var str = decodeURI(serializedString);
var pairs = str.split('&');
var p, idx, val;
for (var i=0, n=pairs.length; i < n; i++) {
p = pairs[i].split('=');
idx = p[0];
var txtBox = this.find('#' + idx + ':input');
if (txtBox.is(":text")) {
txtBox.val(p[1]);
}
}
return this;
};
})(jQuery);
Example of use:
var dataSerialised = sessionStorage.getItem('frmVeryImportantStuff');
if (dataSerialised == null || !confirm("We could restore the previous version of the form you posted. Shall we?"))
return false;
else {
$("#frmVeryImportantStuff").fillformwithserialized(dataSerialised);
}
Obviously you'll need to have saved your form in the sessionStorage in the first place.
Example:
sessionStorage.setItem("frmVeryImportantStuff", $(frmVeryImportantStuff).serialize());