Validating login

The masking language that is used by Masked Text Box is very flexible.

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

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.

You may require that certain text fields not be zero-length, that a field be formatted as a telephone number or other type of well-formed data, or that a string not contain any unsafe characters that could be used to compromise the security of a database.

Windows Forms provides several ways for you to validate input in your application.

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

The Format event on a data binding can be used to reformat incoming data to comply with the mask, and the Parse event can be used to reformat outgoing data to comply with the specifications of the data field. If you want full programmatic control over validation, or need to perform complex validation checks, you should use the validation events built into most Windows Forms controls.

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

If you cancel the Validating event, the data will not be synchronized with the data source.

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.

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

As an alternative you can also try our non-DTD-based validator.