window.onbeforeunload = function() {
if(is_form_changed( )) {
return "Your modifications have not been saved. Are you sure you want to leave?";
}
}
function is_form_changed() {
var t_save = jQuery("#t_save "); //Detect whether the page wants to save the button
if(t_save.length>0) { //Detect the save button and continue to detect whether the element is modified
var is_changed = false;
jQuery("# A4 input, #A4 textarea, #A4 select").each(function() {
var _v = jQuery(this).attr('_value');
if(typeof(_v) == 'undefined ') _v = '';
if(_v != jQuery(this).val()) is_changed = true;
});
return is_changed;
}
return false;
}
jQuery(document).ready(function(){
jQuery("#A4 input, #A4 textarea, #A4 select").each(function() {
jQuery(this ).attr('_value', jQuery(this).val());
});
});