confirm exit does not work correctly for multiple forms

The confirm exit solution does not work correctly for multiple forms on one page because the serialized data are generated over an collection and not over the single forms.