ValidationSummary

A widget for displaying the result of checking validation rules for editors.

Included in: dx.mobile.js, dx.web.js, dx.viz-web.js, dx.all.js
Export: default

This widget has a collection of items that present the validation errors that currently exist in a validation group or the ViewModel to which the widget is related.

dxValidationSummary Widget

You can create the ValidationSummary widget using one of the following approaches.

  • jQuery

    HTML
    <div id="textBox1"></div>
    <div id="textBox2"></div>
    <div id="summary"></div>
    <div id="button"></div>
    JavaScript
    $(function() {
        var validationGroupName = "sampleGroup";
        $("#textBox1").dxTextBox({ name: 'FirstName' })
            .dxValidator({
                validationRules: [
                    // ...
                ],
                validationGroup: validationGroupName
            });
        $("#textBox2").dxTextBox({ name: 'LastName' })
            .dxValidator({
                validationRules: [
                    // ...
                ],
                validationGroup: validationGroupName
            });
        $("#summary").dxValidationSummary({
            validationGroup: validationGroupName
        });
        $("#button").dxButton({
            validationGroup: validationGroupName
            text: 'Validate',
            onClick: function validate (params) {
                params.validationGroup.validate();
            }
        });
    });
  • AngularJS

    HTML
    <div dx-validation-group="{ }" ng-controller="DemoController">
        <div dx-text-box="{ name: 'FirstName' }"
             dx-validator="{
                 validationRules: [
                     // ...
                 ]
             }">  
        </div>
        <div dx-text-box="{ name: 'LastName' }"
            dx-validator="{
                 validationRules: [
                     // ...
                 ]
             }">
        </div>
        <div dx-validation-summary="{  }"></div>
        <div dx-button="{
            text: 'Validate',
            onClick: validate
        }"></div>
    </div>
    JavaScript
    angular.module('DemoApp', ['dx'])
        .controller("DemoController", function ($scope) {
            $scope.validate = function validate (params) {
                params.validationGroup.validate();
            };
        });
  • Knockout

    HTML
    <div data-bind="dxValidationGroup: { }" >
        <div data-bind="dxTextBox: { name: 'FirstName' },
            dxValidator: {
                validationRules: [
                    // ...
                ]
            }">  
        </div>
        <div data-bind="dxTextBox: { name: 'LastName' },
            dxValidator: {
                validationRules: [
                    // ...
                ]
            }">
        </div>  
        <div data-bind="dxValidationSummary: { }"></div>
        <div data-bind="dxButton: {
            text: 'Validate',
            onClick: function validate (params) {
                params.validationGroup.validate();
            }
        }"></div>
    </div>
  • ASP.NET MVC Wrappers

    using (Html.DevExtreme().ValidationGroup()) {
        @(Html.DevExtreme().TextBox()
            .Name("FirstName")
        )
        @(Html.DevExtreme().TextBox()
            .Name("LastName")
        )
        @(Html.DevExtreme().ValidationSummary())
        @(Html.DevExtreme().Button()
            .Text("Validate")
            .OnClick(@<text>
                function validate (params) {
                    params.validationGroup.validate();
                }
            </text>)
        )
    }

Note that DevExtreme widgets require you to link the jQuery library to your application. If you use the Knockout or AngularJS approach, the Knockout or AngularJS library is also required. For detailed information on linking these libraries to your project, refer to the topics in the Installation section.

The summary items are displayed using the default item template that is based on the message field of the broken validation rule. However, you can use a custom item template.

See Also
NOTE
The currently existing validation errors are not only the errors that are discovered during the current validation, but also the validation errors that are discovered during the earlier validations if the not-valid values are not changed since then.

To learn more on how to create the ValidationSummary widget and associate it with the required validation group or ViewModel, refer to the Display Validation Errors and Validate View Model topics.

Watch Video

See Also
Show Example:
AngularJS
Knockout
jQuery

Configuration

An object defining configuration options for the widget.

Methods

This section describes members used to manipulate the widget.

Events

This section describes events fired by this widget.

Default Item Template

This section lists the data source fields that are used in a default item template.

By default, a predefined item template is applied to display the items of this widget. This template is based on certain fields of the data source provided for this widget. Below is the list of these fields. If the default item template is not appropriate for your task, implement a custom item template based on these or other fields of your data source.

See Also