We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set “validationRules” property of columns in AngularJS

How to set validationRules” property of columns in AngularJS

Solution

We can set all the standard validation methods of jQuery as a validation rules for columns. In the below table we have listed some of the jQuery validation methods and explain how to set these rules for columns in AngularJS

Rules

Description

required

Requires an element.

minlength

Requires the element to be of given.

maxlength

Requires the element to be of given maximum length.

range

Requires the element to be in a given value range.

number

The element requires a decimal number.

rangelength

Requires the element to be in given value range

 

Please find more jQuery validation methods from the below UG documentation link

Link: https://help.syncfusion.com/js/grid/editing#column-validation

Please find the below code snippet:

<div ej-grid id="Grid" e-datasource="data" e-toolbarsettings="toolbar" e-editsettings = "editing">

        <div e-columns>

            <div e-column e-field="EmployeeID" e-headertext="Employee ID" e-isprimarykey ="true" e-validationrules-required="true" e-validationrules-number="true"></div>

            <div e-column e-field="LastName" e-headertext="Last Name"></div>

            <div e-column e-field="FirstName" e-headertext="First Name" e-validationrules-maxlength="16" e-validationrules-minlength="5"></div>

            <div e-column e-field="Title" e-headertext="Title" e-validationrules-range="range"></div>

        </div>

    </div>

    <script>

        angular.module('listCtrl', ['ejangular'])

          .controller('EmployeeView', function ($scope) {

              $scope.data = window.employeeView,

              $scope.toolbar = { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] },

              $scope.editing = { allowEditing: true, allowAdding: true, allowDeleting: true },

              $scope.range = [0, 5]

          });

    </script>

 

Result:

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
7131 10/27/2016 10/27/2016 JavaScript ejGrid
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon