add before unload event to forms

Fix AUTO-809