[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Collapse]Data Editors
    Included Components
   [Expand]Implementation Details
   [Expand]Getting Started
   [Expand]Editor Types
   [Collapse]Common Features
    [Expand]Obtaining Editor Values
    [Expand]Binding to Data
     In-Place Mode
    [Expand]Editor Operation Modes
    [Expand]Masked Input
    [Collapse]Input Validation
      Input Validation Overview
      Input Validation Types
     Incremental Search
   [Expand]Range Control
   [Expand]Visual Elements
   [Expand]End-User Capabilities
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Input Validation Types

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.

Expanded 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.

Expanded 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.

Is this topic helpful?​​​​​​​