Data Editors - Common Features Built-in Validation


The following validation rules are defined in this demo: Name: required, must be under 50 characters; Age: required, must be between 18 and 100; Email: required, must fit email regular expression; Arrival date: required

This demo illustrates the built-in flexibility and efficiency of our MVC data validation engine, allowing you to easily implement different validation scenarios. Validation settings can be customized for a given editor by using the editor's ValidationSettings property.

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

  • The RequiredField property can be used to force an editor to require input and give you the ability to display an error message if input is not received.
  • The RegularExpression property allows you to validate an editor's value based upon a regular expression.
  • An editor's Validation client event can be handled to setup custom editor validation. Review the code sample tabs within this demo, to learn how easy this really is.

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 ValidateEditorsInContainer, ValidateEditorsInContainerById, ValidateGroup).

When an editor fails validation logic, a specific error frame containing the error’s description can be displayed. The Display property controls how the error frame occupies space around the editor. The error frame's appearance is customized via the ErrorFrameStyle property. Based upon ErrorDisplayMode 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 ErrorImage property. The error text can be specified by using either the ErrorText property or in the Validation event's handler.

See Also:
Version: v2017 vol 1.7
Copyright © 2006-2017 Developer Express Inc
Your Next Great MVC App Starts Here

Get started today and download your 30-day trial of DevExpress MVC Extensions (includes 30 days of free technical support).

All demos ship with full source code and are included in the DevExpress MVC distribution. Refer to the Demos and Sample Applications topic to learn more.

DevExpress MVC Extensions ship as part of DevExpress Universal, DXperience and ASP.NET Subscriptions and are backed by a 60 day unconditional money-back guarantee.
To learn more and obtain pricing information, visit the Compare Features and Pricing webpage. For immediate assistance, contact us by Email at or by phone at +1 (818) 844-3383 between 7:30am and 4:30pm Pacific Time.