What is the best way to allow canceling of a modal form when there is field level validation?

delphi, validation

Solution

I abandoned data validation "on field exit" altogether. It frustrates users who know what they're doing (for example, someone may be copying data from another source and pasting on the current screen, in a way that will only make sense only when all data is pasted in--validation per field usually gets on the way of such actions).

Instead, try performing data validation when the user is ready to move on from the current screen, usually when they click the "OK" or "Next" button.

Problem

What is the best way to allow canceling of a modal form when there is field level validation? I have a Delphi form shown modally. In it there are TComboBoxes, TEdits, an Ok and Cancel buttons. These fields have OnExit methods the fire to check that the data is valid. However, I would like to have the Cancel button click allow the form to close without validating the fields. What happens is when the Cancel button is clicked, then the OnExit of the field is called and validation is run before the OnClick of the button which closes the form. This timing is undesirable because it causes the user to correct data that they wish to abandon. Thanks.

Original source