JavaScript/jQuery Validator - PatternRule
import { PatternRule } from "devextreme/common"
Type:
To specify the regular expression that the validated field must match, set the rule's pattern configuration property.
NOTE
If you apply a pattern rule to a DateBox component, specify dateSerializationFormat so that the format of the validated value is a string.
See Also
message
Type:
Default Value: 'Value does not match pattern'
An error message can be specified as follows:
Hard-code the message
index.js- $(function() {
- $("#textBox").dxTextBox({ ... })
- .dxValidator({
- type: "pattern",
- message: "My custom message"
- });
- });
Hide the message
index.js- $(function() {
- $("#textBox").dxTextBox({ ... })
- .dxValidator({
- type: "pattern",
- message: ""
- });
- });
Display the editor's name in the message
index.js- $(function() {
- $("#textBox").dxTextBox({ ... })
- .dxValidator({
- name: "Phone number", // The error message will be "Phone number does not match pattern"
- validationRules: [{
- type: "pattern"
- }]
- });
- });
Feedback