Validating login

14-Mar-2020 07:42

To validate your controls, you will have to use explicit validation.

The explicit validation approach validates data at one time.

Each control that accepts free-form user input has a Validating event that will occur whenever the control requires data validation.

In the Validating event-handling method, you can validate user input in several ways.

When you use data binding, the data in your control is synchronized with the data source during execution of the Validating event.

It allows you to specify required characters, optional characters, literal characters, such as hyphens and parentheses, currency characters, and date separators.If you want to use implicit validation for a control, you must set that control's Auto Validate property to .If you cancel the Validating event, the behavior of the control will be determined by what value that you assigned to Auto Validate.If you do not set the Cancel property, Windows Forms will assume that validation succeeded for that control, and raise the Validated event.

For a code example that validates an email address in a Text Box, see Validating.Important If you have custom validation that takes place after the Validating event, it will not affect the data binding.For example, if you have code in a Validated event that attempts to cancel the data binding, the data binding will still occur.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.