I have a form which we can edit while clicking the edit button. While doing that i’m using the following script for showing the error message before leaving the page. It is showing the error message while clocking or leaving the page . But the problem is while saving the form it is submitting to some other page that time also it is showing the warning message. I want to remove the error message while submitting the form. The script is
function updateNew(value) {
$(window).bind('beforeunload', function(){
return 'Are you sure you want to leave?';
});
}
<a href="#" onclick="updateNew({$ad_details[customer].id});"> Edit</a>
make a global variable like this
and after that in your function check for that variable value
first set value of
Updatedtotruewhile submitting your form. this will do the trick for you.