[FX.php List] A little JQuery/javascript help

Jonathan Schwartz jschwartz at exit445.com
Sun Aug 26 17:06:14 MDT 2012


Hi Folks,

I've added a short script to a page to help remind the user to save 
their data before leaving a form.  I found the script in a JQuery 
page, but don't know how to make a needed modification.

It works as needed if the user tries to leave the page. But, it also 
warns the user when the Submit button is clicked to save the data. 
That's one case where it should not produce a warning.

Anyone know how to disarm the script in the single case of when the 
submit button is clicked, the javacsript equivalent of

	if(!isset($_POST['submit']))...

Thanks.

JOnathan



<script lanuage="Javascript">
var form_clean;

// serialize clean form
$(function() {
     form_clean = $("form").serialize();
});

// compare clean and dirty form before leaving
window.onbeforeunload = function (e) {
     var form_dirty = $("form").serialize();
     if(form_clean != form_dirty) {
         return 'There is unsaved Event data.';
     }
};
</script>
-- 
Jonathan Schwartz
Exit 445 Group
jonathan at exit445.com
http://www.exit445.com
415-370-5011


More information about the FX.php_List mailing list