JavaScript/jQuery Validator - EmailRule

A validation rule that requires that the validated field match the Email pattern.

import { EmailRule } from "devextreme/common"
Type:

Object

View Demo

DevExtreme components use the following Email pattern:

Code
  • pattern: /^[\d\w._-]+@[\d\w._-]+\.[\w]+$/i
See Also

ignoreEmptyValue

If set to true, empty values are valid.

Type:

Boolean

Default Value: true

message

Specifies the message that is shown if the rule is broken.

Type:

String

Default Value: 'Email is invalid'

You can configure an error message in the following ways:

  • Specify a hard-coded message:

    index.js
    • $("#textBox").dxTextBox({
    • // ...
    • }).dxValidator({
    • type: "email",
    • message: "My custom message"
    • });
  • Hide the message:

    index.js
    • $("#textBox").dxTextBox({
    • // ...
    • }).dxValidator({
    • type: "email",
    • message: ""
    • });
  • Display the editor's name in the default message (for instance, "Mail address is invalid"):

    index.js
    • $("#textBox").dxTextBox({
    • // ...
    • }).dxValidator({
    • name: "Mail address",
    • validationRules: [{
    • type: "email",
    • }],
    • });

type

Specifies the rule type. Set it to "email" to use the EmailRule.