My solution to alert the user when data is not saved:
Add this in onApplicationInit event of the form:
echo “<script>var Haschanged = 0; window.addEventListener(‘beforeunload’, function( event ) {if(Haschanged == 1) event.returnValue = ‘Message to display when leaving’;});</script>”;
Add javascript for Form->OnSubmit so there will be no prompt if the record is saved:
function sc_form_onsubmit()
{
Haschanged = 0;
}
For every field that you want to “monitor” add javascript Field->OnChange
function sc_MyField_onchange()
{
Haschanged = 1;
}
You will now get an option to leave or stay on the page if any of the “monitored” fields has changed…