Warn user that data may be lost for custom pages

you have to make a javascript code similar to this…

jQuery(function ($) {

    name = $('#name').val();
    $('#name').data('old_value',name);

    window.onbeforeunload = function () {
        if ($('#name').data('old_value') !== $('#name').val())
            return 'You have unsaved changes!';
    }

});

here’s a demo page… try closing the page after changing the value of the textbox there…