Validating form elements

Input focus will remain on the current control until the user changes the data to a valid input.If you assigned Enable Allow Focus Change, the Validated event will not occur when you cancel the event, but focus will still change to the next control.The implicit validation approach validates data as the user enters it.

For example, if you have code in a Validated event that attempts to cancel the data binding, the data binding will still occur.

In this case, to perform validation in the Validated event, change the control's Data Source Update Mode property (under (Databindings)\(Advanced)) from On Validation to Never, and add So when does a control's data get validated? You can use either implicit or explicit validation, depending on the needs of your application.

The explicit validation approach validates data at one time.

You can validate the data in response to a user action, such as clicking a Save button or a Next link.

You can still use control validation to lock focus to a control, but you do not have to be concerned about the behavior associated with closing the form.

This method sets up event handlers for submit, focus, keyup, blur and click to trigger validation of the entire form or individual elements.

It allows you to specify required characters, optional characters, literal characters, such as hyphens and parentheses, currency characters, and date separators.

The control also works well when bound to a data source.

In the event, set the Cancel property to Note If you force the form to close in this manner, any data in the form's controls that has not already been saved is lost.

In addition, modal forms do not validate the contents of controls when they are closed.

Assigning Disable to the Auto Validate property prevents implicit validation altogether.