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.
There are two ways of validating forms with React Final Form: record-level and field-level. Record level is pretty much the same as how it's done with Formik. And just like Formik, you can also easily use Yup for implementing validation rules.
Basic Validation − First of all, the form must be checked to make sure all the mandatory fields are filled in. It would require just a loop through each field in the form and check for data. Data Format Validation − Secondly, the data that is entered must be checked for correct form and value.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With