Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]ASP.NET WebForms Controls
 [Collapse]ASP.NET MVC Extensions
  [Expand]Product Information
  [Expand]Getting Started
  [Expand]Common Concepts
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]HTML Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Navigation and Layout Extensions
  [Expand]File Management
  [Expand]Multi-Use Site Extensions
  [Expand]Charts
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Tree List
  [Collapse]Data Editor Extensions
    Editor List
    Main Features
   [Collapse]Common Concepts
     Binding Data Editors to Data
     Getting Editor Values
     Mask Editing
    [Collapse]Validation
      Validation Overview
      Model Validation
      Unobtrusive Client Validation
      jQuery Client Validation
      Built-in Validation
      Remote Validation
      Displaying Validation Error Messages
      Validating Dynamically Loaded Forms
     Accessibility Support
   [Expand]Editor Types
   [Expand]Strongly-Typed Editor Types
  [Expand]Report Extensions
  [Expand]SpellChecker
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Built-in Validation

DevExpress MVC data editors provide a built-in server and client side validation API. An editor's validation settings can be customized on the client and server separately. You can use one or both validation approaches.

Note

Built-in validation is not performed when specifying validation attributes for a model class properties (Unobtrusive Client Validation).

Expanded Server Side Validation

To define editor validation logic, use the following (can be combined if required):

When an editor fails validation logic, a specific error frame containing the error's description can be displayed. The ValidationSettings.Display property controls how the error frame occupies space around the editor.

The error frame's appearance can be customized via the ValidationSettings.ErrorDisplayMode property. The ValidationSettings.ErrorFrameStyle settings specify whether the error's description is displayed as an image or text (or both) in an error frame. To define an error image, use the ValidationSettings.ErrorImage property. The error text can be specified using the ValidationSettings.ErrorText property or Validation event's handler.

The code sample below demonstrates how to perform a validity check on the server side.

View code (Razor):

Controller code ("ValidationController.cs"):

Expanded Client Side Validation

An editor's Validation client event can be handled to setup custom editor validation.

Editor validation is automatically triggered by changing the editor's value whenever the ValidationSettings.ValidateOnLeave option is enabled. You can manually initiate editor validation using the editor's Validate client method or specific static client methods (such as the ASPxClientEdit.ValidateEditorsInContainer, ASPxClientEdit.ValidateEditorsInContainerById, ASPxClientEdit.ValidateGroup).

The code sample below demonstrates how to perform a validity check on the client side.

Expanded See Also

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