JavaScript/jQuery Validator - RequiredRule
A validation rule that rejects empty and invalid values.
The following values break RequiredRule:
- Falsy JavaScript values except
0,-0,0n, andNaN. - Invalid values for the target editor (for example, a non-numeric string for the NumberBox component).
See Also
message
Specifies the message that is shown if the rule is broken.
You can configure an error message in the following ways:
Specify a hard-coded message:
index.js- $("#textBox").dxTextBox({
- // ...
- }).dxValidator({
- type: "required",
- message: "My custom message"
- });
Hide the message:
index.js- $("#textBox").dxTextBox({
- // ...
- }).dxValidator({
- type: "required",
- message: ""
- });
Display the editor's name in the default message (for instance, "Password is required"):
index.js- $("#textBox").dxTextBox({
- // ...
- }).dxValidator({
- name: "Password",
- validationRules: [{
- type: "required",
- }],
- });
trim
Indicates whether to remove the Space characters from the validated value.
To keep the Space characters within the validated value, set this field to false.