HTML5 get set form data in localstorage

Get set html form data in localstorage html5. javascript – Save Form using localstorage HTML5. How can i use localstorage to save form data. How to save data from a form with HTML5 local storage. Saving form state with jQuery and localstorage.

Set form data in localstorage

if(localStorage){
    localStorage.setItem('myForm', JSON.stringify($('#myForm').serializeArray()));
}

Get form data from localstorage

if(localStorage){
    var myForm = JSON.parse(localStorage.getItem('myForm'));
    if(myForm && myForm.length){
        $(myForm).each(function(ind, myField){
            alert(myField['name']+' : '+myField['value']);
        });
    }
}