How to Show confirmation alert while exit page with pending changes?
by barkkathulla[ Edit ] 2013-10-19 14:18:28
Show confirmation alert while changing/closing the window
Script portion
function enableUnload() {
window.onbeforeunload = function (e) {
if(window.nounloadcheck == true) return
return "R u sure to avoid this pending changes?";
};
}
Form design
1.Here you can use nounloadcheck function in form onsubmit portion like below,
<form method="post" action="" enctype="multipart/form-data" onsubmit="window.nounloadcheck = true; return true;">
Reason is this method is to avoid confirmation alert while clicking submit button...
2.You can call enableUnload function in your textarea like below,
<tr>
<td>
<textarea id="qdesc" name="qdesc" class="cmd_textarea" rows = "10" cols = "30" onkeyup="enableUnload();">
<?php echo $qdesc; ?>
</td>
</tr>
This code prevents data loss when a link is clicked by mistake....