How to detect form-field change when window-close

Is it possible to detect if any of the fields in the form changed content since it was first displayed.
If changes where made I want to display the client with a message i.e. like this "You have made changes, do you want to save the record?".... (YES) ... (NO)...

And that this check is only done when the user tries to close (and if possible) leave the window that holds the form.

Would prefere this to be done in JavaScript.
And that it works both in NS and IE.

In terms of the user closing the browser, well you can use the same code above, but this is where you start hitting problems with cross-browser compatibility.

You could try using the onunload event in the <body> tag e.g.

<body onunload="return checkAltered():">

but then you'll probably now want the browser warning appearing etc.etc. (unless the window you are working in was opened by your page using window.open()) and there is little you can do about that. :o)

I personally always convince my clients (if they need this kind of functionality) that it is better stick with controlling what is in the page and not outside of it if they want their code to work properly in different browsers.

I have a hidden variable as my global variable defaulted to N, ao any changes on the form update it to Y and while exiting or closing the window check this hidden varible value if its "Y" implies somechanges are there to save, so alert a message as you want.
<html>
<head>
<script language="javascript">

I have a hidden variable as my global variable defaulted to N, ao any changes on the form update it to Y and while exiting or closing the window check this hidden varible value if its "Y" implies somechanges are there to save, so alert a message as you want.
<html>
<head>
<script language="javascript">

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

podishetty: You seem to have been member long enough to know that proposing an answer (and a wrong one at that - and even worse - reusing code given by an expert in a previous comment) is not on after comments have been given.

Michel
Ant: I actually do not conciously try to reach 3000 points - I just hope I will not loose status if I do not reach them - I have been off EE for a while and then back on and have not been hunting points for a long while

This question is LOCKED with a Proposed Answer. If it helps you, great, accept it and grade it to close. If not, reject it and comment as to why or what else is needed.

Few additional experts will join this collaboration effort, once a question has been locked. Just want to confirm this to you. If more than one expert helps you, you can always split points or award additional help in a new question, within the same topic area. If you need help from us, post a zero point question here, and include the link:

I am implementing an event in which it will show a popup window that contain several questions to answer. This event will only display after i close the browser. But i have a problem. When i refresh tha page it will show the popup window and if i press a link on the page again it will show the popup window. It should only display the popup window if i close the page. How can i implement this in javascript..

</SCRIPT>
</head>
<body onUnload="MM_openBrWindow('exitpage.php','exitpage','width=300,height=400')">
<div align="center"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Try
to refresh the window will not popup . try to click the link still the window
will not popup. it will only popip if you close the browser. Without this script,
all events in this page will trigger the window to popup.</strong></font> </div>
<FORM NAME="myForm">
<div align="center">
<INPUT TYPE="hidden" VALUE="" NAME="check">
<a href="http://www33.brinsker.com/softcomputing">Link to my page</a> </div>
</form>
</body>
</html>

Featured Post

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

The viewer will learn the basics of jQuery, including how to invoke it on a web page.
Reference your jQuery libraries: (CODE)
Include your new external js/jQuery file: (CODE)
Write your first lines of code to setup your site for jQuery.: (CODE)

The viewer will learn the basics of jQuery including how to code hide show and toggles.
Reference your jQuery libraries:
(CODE)
Include your new external js/jQuery file:
(CODE)
Write your first lines of code to setup your site for jQuery…