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]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]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Built-in Validation

DevExpress MVC data editors provide you with a built-in server and client side validation API. Validation settings for a given editor can be customized on the client and server separately. You are free to use one or both of these validation approaches.

Expanded Server Side Validation

To define editor validation logic, use the following (can be combined together whenever 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. Based upon ValidationSettings.ErrorFrameStyle settings, the description of an error can be represented within the error frame using an error image or text (or both). To define an error image, use the ValidationSettings.ErrorImage property. The error text can be specified by using either the ValidationSettings.ErrorText property or in the 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 by 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

How would you rate this topic?​​​​​​​