JavaScript/jQuery Validator Options
An object defining configuration properties for the Validator UI component.
See Also
adapter
An object that specifies what and when to validate, and how to apply the validation result.
This property should be specified when you cannot associate the Validator UI component with an editor, for instance, when you use custom editors or a validated value is a sequence of several DevExtreme editor values. Refer to the Validate a Custom Value topic for more details.
See Also
elementAttr
Specifies the global attributes to be attached to the UI component's container element.
jQuery
$(function(){ $("#validatorContainer").dxValidator({ // ... elementAttr: { id: "elementId", class: "class-name" } }); });
Angular
<dx-validator ... [elementAttr]="{ id: 'elementId', class: 'class-name' }"> </dx-validator>
import { DxValidatorModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxValidatorModule ], // ... })
Vue
<template> <DxValidator ... :element-attr="validatorAttributes"> </DxValidator> </template> <script> import DxValidator from 'devextreme-vue/validator'; export default { components: { DxValidator }, data() { return { validatorAttributes: { id: 'elementId', class: 'class-name' } } } } </script>
React
import React from 'react'; import Validator from 'devextreme-react/validator'; class App extends React.Component { validatorAttributes = { id: 'elementId', class: 'class-name' } render() { return ( <Validator ... elementAttr={this.validatorAttributes}> </Validator> ); } } export default App;
height
Specifies the UI component's height.
This property accepts a value of one of the following types:
Number
The height in pixels.String
A CSS-accepted measurement of height. For example,"55px"
,"20vh"
,"80%"
,"inherit"
.
name
Specifies the editor name to be used in the validation default messages.
All predefined rules have a default message displayed when the rules are not satisfied by the validated editor values. If you specify the name property of the associated dxValidator object, the property value will be used as an object in the default message. For instance, the "Value is invalid" message will be transformed to "Login is invalid", if you set "Login" for the name property.
onDisposing
A function that is executed before the UI component is disposed of.
Information about the event.
Name | Type | Description |
---|---|---|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
onInitialized
A function used in JavaScript frameworks to save the UI component instance.
Information about the event.
Name | Type | Description |
---|---|---|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
Angular
<dx-validator ... (onInitialized)="saveInstance($event)"> </dx-validator>
import { Component } from "@angular/core"; import Validator from "devextreme/ui/data_grid"; // ... export class AppComponent { validatorInstance: Validator; saveInstance (e) { this.validatorInstance = e.component; } }
Vue
<template> <div> <DxValidator ... @initialized="saveInstance"> </DxValidator> </div> </template> <script> import DxValidator from 'devextreme-vue/validator'; export default { components: { DxValidator }, data: function() { return { validatorInstance: null }; }, methods: { saveInstance: function(e) { this.validatorInstance = e.component; } } }; </script>
<template> <div> <DxValidator ... @initialized="saveInstance"> </DxValidator> </div> </template> <script setup> import DxValidator from 'devextreme-vue/validator'; let validatorInstance = null; const saveInstance = (e) => { validatorInstance = e.component; } </script>
React
import Validator from 'devextreme-react/validator'; class App extends React.Component { constructor(props) { super(props); this.saveInstance = this.saveInstance.bind(this); } saveInstance(e) { this.validatorInstance = e.component; } render() { return ( <div> <Validator onInitialized={this.saveInstance} /> </div> ); } }
See Also
onOptionChanged
A function that is executed after a UI component property is changed.
Information about the event.
Name | Type | Description |
---|---|---|
value | any |
The modified property's new value. |
previousValue | any |
The UI component's previous value. |
name |
The modified property if it belongs to the first level. Otherwise, the first-level property it is nested into. |
|
fullName |
The path to the modified property that includes all parent properties. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component |
The UI component's instance. |
onValidated
A function that is executed after a value is validated.
Information about the event.
Name | Type | Description |
---|---|---|
brokenRule |
The object that represents the first broken rule on the list of specified validation rules. |
|
brokenRules |
An array of validationRules that failed to pass the check. |
|
isValid |
Indicates whether the value satisfies all rules. |
|
name |
The value of the name property. |
|
status |
Indicates the validation status. |
|
validationRules |
An array of validation rules specified for the current dxValidator object. |
|
value |
The validated value. |
validationGroup
Specifies the validation group the editor will be related to.
Generally, the editors that are associated with dxValidator objects are validated on each value change. But you can combine several editors into a group so that they are validated together (e.g., on a button click).
The validationGroup property should be specified for the associated dxValidator object to indicate the validation group within which the editor will be validated. Assign the same validation group name for those editors that should be validated together.
See Also
validationRules
An array of validation rules to be checked for the editor with which the dxValidator object is associated.
Array<RequiredRule | NumericRule | RangeRule | StringLengthRule | CustomRule | CompareRule | PatternRule | EmailRule | AsyncRule>
There are several predefined rule types. Each rule type demands a specific set of rule properties. Use the Validation Rules section to learn how to define rules of different types.
width
Specifies the UI component's width.
This property accepts a value of one of the following types:
Number
The width in pixels.String
A CSS-accepted measurement of width. For example,"55px"
,"20vw"
,"80%"
,"auto"
,"inherit"
.
If you have technical questions, please create a support ticket in the DevExpress Support Center.