How to force Safari to warn before leaving a page when a form is filled in but not submitted
Try this in Terminal

defaults write com.apple.Safari DebugConfirmTossingUnsubmittedFormText -integer -1

Which seems slightly odd, as the opposite is -bool false but that's what "Secrets" shows for the 2 alternatives.
http://secrets.blacktree.com/edit?id=2467 ought to be the page with the defaults data for that, but the entire site is coming up 404 today.