[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [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]Tree List
  [Expand]Card View
  [Expand]Pivot Grid
   Rich Text Editor
  [Expand]Site Navigation and Layout
  [Expand]HTML Editor
  [Expand]Vertical Grid
  [Collapse]Data Editors
    Editor List
    Main Features
   [Collapse]Common Concepts
    [Expand]Binding Data Editors to Data
     Getting Editor Values
     Mask Editing
      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
    Filter Control
    Validation Summary
   [Expand]Strongly-Typed Editor Types
  [Expand]Docking and Popups
  [Expand]File Management
  [Expand]Data and Image Navigation
  [Expand]Multi-Use Site Extensions
  [Expand]Spell Checker
  [Expand]Query Builder
 [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]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)

Model Validation

DevExpress MVC data editors support a model-based data validation approach which is implemented in ASP.NET MVC 2 and 3. This approach is based on decorating model class properties with the DataAnnotations attributes. You can learn more about model validation from this blog post: ASP.NET MVC 2: Model Validation.

This topic describes how to add a validity check to the DevExpress MVC data editors.

To implement user-input validation within DevExpress MVC Data Editors, you need to perform the following steps.

Expanded Adding Validation Rules to the Model Class

To define validation rules for the user input, add the required DataAnnotation attributes to the respected model class properties. Server-side validation is automatically enabled when data annotations are added. You can learn more about DataAnnotation attributes usage in ASP.NET MVC validation from this blog post: How data annotations for ASP.NET MVC validation work.

Expanded Validation-Specific Settings for Data Editors

Displaying Validation Error Messages.

You have the ability to use different approaches to display validation error messages: standard ValidationMessageFor() and ValidationSummary() methods, the DevExpress MVC editors built-in placeholder and DevExpress MVC Validation Summary. You can find these approaches described here: Displaying Validation Error Messages.

Additional requirements.

Note that the editor's Name property value must match the related data model class property name.

The ASP.NET MVC Framework requires your input data editors to be inside of a <form> element that should be rendered with Html.BeginForm() in order to be validated.


The code sample below demonstrates how you can configure the TextBox extension to render the validation error message within a built-in placeholder.

You can see the rendered result in the picture below.

Expanded Enabling Client-Side Validation

After the previous steps, your application only performs server-side validation: end users will need to submit a form to the server before they will see a validation error messages.

In addition to server-side validation, you can enable client-side validation functionality.

The client-side validation requires MicrosoftAjax.min.js, MicrosoftMvcAjax.min.js and MicrosoftMvcValidation.min.js JavaScript references to be included in your layout or master page (or to a certain views that contain validating forms).

The code sample below demonstrates how to include the required javascript references.


The JavaScript references should be added in the order they are specified in the code sample above.

To enable client-side validation for all pages in your project, add a key to web.config.

To enable the client-side validation functionality for a specific view only, you can add the following code to the required view.


The model validation script parses loaded DOM searching for forms that contain validation metadata. The parsing is only done after the initial page load, so the forms that were loaded via callbacks after the page load are not parsed. See this topic to learn how to validate forms that were loaded via callbacks: Validating Dynamically Loaded Forms.

Expanded See Also

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