How do I let users know that “there are changes left to be saved on the form if they try to close the browser window?”
I have a form with couple of fields, Now if the user changes some of the fields and clicks on Close button on the browser window, my script should alert him of unsaved changes. How do I implement this? I have put in basic form validation but can’t seem to think of a solution for window.close() event. Any sample links would be helpful.
How do I let users know that there are changes left to be saved
Share
Well you could use the body
onbeforeunloadoronunload.Never used a return to stop a page unload before but it should work.
Update:
In the header of the web page to make it a global var:
In the body(of course):