Skip to main content
A newer version of this page is available. .

Input Validation Types

  • 2 minutes to read

When creating applications that allow users to input values, it is important to check the validity of the entered values. The editors in the DXEditors for WPF Library provide automatic and manual input validation facilities.

Automatic Validation Using Masks

User input is automatically controlled by the editor when using the mask functionality. Masks let you specify the pattern used to input values and an end-user cannot enter text which is not permitted by the mask. So, in masked mode, entered values always match the edit masks.

Manual Validation

In some cases, however, you may want to provide manual validation control (limit the range of valid values, implement a conditional validation mechanism, etc.). For this purpose the BaseEdit.Validate event should be handled. This event lets you check the value entered into an editor before it is accepted. If the value entered does not meet your restrictions, or is of the wrong type, you can indicate that the current value has failed validation.

The BaseEdit.Validate event is raised for an editor, if the editor’s BaseEdit.CausesValidation property is set to true. Editor validation can be fired in the following cases:

You can also use the BaseEdit.DoValidate method to perform validation at any desired moment (for instance, within a handler of the LookUpEditBase.SelectedIndexChanged event of a combo box editor).

To indicate that the edit value has failed validation, set the ValidationEventArgs.IsValid property of the BaseEdit.Validate event’s argument to false. Depending upon the BaseEdit.InvalidValueBehavior property’s setting, an editor can respond to inputting an invalid value by either locking the entire application until a correct value is entered, or allowing an end-user to switch to another editor and re-enter a value for this editor later.