JavaScript/jQuery Validator - NumericRule
A validation rule that demands that the validated field has a numeric value.
import { NumericRule } from "devextreme/ui/validation_rules"
Type:
message
Specifies the message that is shown if the rule is broken.
Type:
Default Value: 'Value should be a number'
An error message can be specified as follows:
Hard-code the message
index.js- $(function() {
- $("#textBox").dxTextBox({ ... })
- .dxValidator({
- type: "numeric",
- message: "My custom message"
- });
- });
Hide the message
index.js- $(function() {
- $("#textBox").dxTextBox({ ... })
- .dxValidator({
- type: "numeric",
- message: ""
- });
- });
Display the editor's name in the message
index.js- $(function() {
- $("#textBox").dxTextBox({ ... })
- .dxValidator({
- name: "Age", // The error message will be "Age should be a number"
- validationRules: [{
- type: "numeric"
- }]
- });
- });