I have this little piece of code:
if you're using bind then use this:
$('form').submit(function () { $(window).unbind('beforeunload'); });
This will be good for all form submit.