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
  [Collapse]Common Concepts
    Web Application Project Templates
    Insert Extension Wizard
    Data Binding
   [Expand]Applying Themes
    Client-Side API
    Declaring Server-Side Event Handlers
    Templates
    Using Callbacks
    Passing Values to a Controller Action through Callbacks
    Supported Attributes for Model Validation
    Using Extensions in Razor Views
  [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
  [Expand]Data Editor Extensions
  [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

Supported Attributes for Model Validation

DevExpress MVC Extensions support a model-based data validation approach that is based on decorating model class properties with validation attributes.

The System.ComponentModel.DataAnnotations namespace contains the following attributes which you can use within the DevExpress MVC Extensions to enforce validation rules for data applied to a class or member:

Validation Attribute Description
CreditCardAttribute Specifies that a data field value is a credit card number.
EmailAddressAttribute Validates an email address.
FileExtensionsAttribute Validates file name extensions.
MaxLengthAttribute Specifies the maximum length of array or string data allowed in a property.
MinLengthAttribute Specifies the minimum length of array of string data allowed in a property.
PhoneAttribute Specifies that a data field value is a well-formed phone number using a regular expression for phone numbers.
RangeAttribute Specifies the numeric range constraints for the value of a data field.
RegularExpressionAttribute Specifies that a data field value in ASP.NET Dynamic Data must match the specified regular expression.
RequiredAttribute Specifies that a data field value is required.
StringLengthAttribute Specifies the minimum and maximum length of characters that are allowed in a data field.
UrlAttribute Provides URL validation.

The model-based validation allows you to validate user-input on the server when an end-user adds or edits data via the GridView or TreeList. DevExpress MVC Data Editors support client and server-side validation. Refer to this help topic to learn more: Validation Overview.

Remote Validation

ASP.NET MVC 3 provides a remote validation approach: a mechanism that can make a remote server call in order to validate a form field without posting the entire form to the server. This validation approach is implemented using the RemoteAttribute from System.Web.Mvc namespace. DevExpress MVC Data Editors support the remote validation approach and the [Remote] attribute. Refer to the Remote Validation topic to learn more.

This demo shows how to implement remote validation with the [Remote] attribute and jQuery: jQuery Client Validation.

Review this MSDN topic to learn more about remote validation: How to: Implement Remote Validation in ASP.NET MVC.

DevExpress Mask Attribute

The DevExpress ASP.NET MVC editors allow you to use masks during editing. Masks are useful when a string entered by an end-user into an editor must match a specific format. For instance, a text editor that accepts date/time values in the 24-hour format only, or only numeric values, or a phone number that only allows an end-user to enter digits into automatically constructed placeholders.

You can define the mask settings for a model field using the DevExpress Mask attribute and the mask pattern will automatically be displayed within the text area of the DevExpress MVC Data Editors. The Mask attribute enables the validation mechanism that checks whether the entered value matches the mask expression. The decorated model field will be automatically validated on the server side.

Note

The DevExpress Mask attribute enables validation of user input on the server side. If you use any other third-party text editor, like the standard Html.TextBoxFor helper, the server-side validation mechanism is still triggered.
Only the DevExpress ASP.NET MVC Data Editors can retrieve mask settings defined using the DevExpress Mask attribute from the metadata and display a mask pattern in the edit area.

The Mask attribute is implemented by the MaskAttribute class.

The code sample below demonstrates how to decorate a model field with the Mask attribute.

The image below illustrates the look of a DevExpress ASP.NET MVC TextBox extension bound to a field decorated with a DevExpress Mask attribute as shown in a code sample above.

Expanded See Also

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