Rules
- Last UpdatedJun 22, 2023
- 1 minute read
Rules validate the value of a control.
Rule Structure
|
Object |
Description |
|---|---|
|
RuleFor |
Associated property for the rule. |
|
RuleName |
JavaScript function name for the rule. This name is used in the client-side JavaScript and this JavaScript function is called when the rule is executed. |
|
RuleDefinition |
Error message for the rule. |
|
ControlType |
Associated control for the rule. |
|
RenderMode |
Render the control in HTML5 or HTML. |
Lost Focus Rules
Lost focus rules trigger when a control looses focus or when a form is submitted.
Example
rules.Add(new Rule { RuleFor = "lostFocus", RuleName = "RuleName", RuleDefinition = "Error Message", ControlType = this.GetType().Name, RenderMode = RenderingMode.Html5.ToString() });
Value Rules
Value rules are triggered when the value of a control changes or when a form is submitted.
Example
rules.Add(new Rule { RuleFor = "Value", RuleName = "RuleName", RuleDefinition = "Error message", ControlType = this.GetType().Name, RenderMode = RenderingMode.Html5.ToString() });
Note:
- RuleName defined in the control class file is used as is in the client-side JavaScript function.
- When a rule in the Rules collection fails, further rules are not executed.