I am coding a form and I need a function like stackoverflow have: \"You have started writing or editing a post.\".
I\'ve looked through the code of stackoverflow to
This is how in JQuery
$('#form').data('serialize',$('#form').serialize());
// On load save form current state
$(window).bind('beforeunload', function(e){
if($('#form').serialize()!=$('#form').data('serialize'))return true;
else e=null;
// i.e; if form state change show box not.
});
You can Google JQuery Form Serialize function, this will collect all form inputs and save it in array. I guess this explain is enough :)