Control Validation
Validation patterns are expressions that you configure to validate data. You can select a validation pattern from a list of patterns or you can create custom validation patterns. You can also customize the validation message and choose to display the validation failure as a red outline on the control (the default) or in a popup dialog. See How To: Use Regular Expressions to Validate Control Values for an example of using regular expressions to validate values of controls in a view or form.
You can apply validation to the following controls using the Pattern field of the control's properties.
- Auto-Complete
- Data Label
- Text Area
- Text Box
You apply a validation pattern to your control by clicking the ellipsis next to the Pattern property of the control, and then select the pattern you need from the Validation Patterns. On this page you can add, edit, and remove patterns. However, be careful when you do this because changing or removing a pattern applies to all controls using that pattern in every view and form on the server. When you are modifying or deleting patterns, a Dependencies dialog may appear, which will report the identified dependency issues that will exist if the action is completed.
For validation patterns to work, you must execute the The View/Form passes validation rule condition. The rule controls when the condition applies. You must also configure the condition to specify the controls on which the validation executes. The validation happens at runtime when this rule is called.
Keep in mind that validation rules for Item views are slightly different than using them with Editable List views.
When applying a validation rule to an Item view, the definition should look something like this:
When applying a validation rule to an Editable List view, the definition should look something like this:
When you configure the validation, you can set the validation per control, marking some controls as required and some to be validated.
Feature | Description | How to use it |
---|---|---|
Required |
Requires a value for the validation to succeed. A required control is validated using the data type of the control. |
Select the controls that must have a value |
Validate |
Validates the value of the control against the data type of the control. For example, does a Number control contain a valid number. |
Select the controls to validate |
Show validation messages in a popup dialog | A dialog displays containing the validation message when validation fails | Select the option if you want to display the message in a dialog. If you do not select this option, validation failures appear as red boxes around the control, and the message is displayed in a tooltip. |
Do not validate hidden, disabled or read-only controls, Views and tabs | You can use rule actions to hide or disable views and tabs, or you can use the Visible, Enabled and Read-Only properties of controls, views and tabs. When you select this option, all controls in these states are ignored when validation is performed, i.e. no validation is executed for hidden, disabled, and read-only controls. The option to not validate these controls also applies to controls and views that are hidden or disabled by a rule during runtime. | On by default, uncheck this option if you want hidden, disabled, and read-only controls validated (not recommended). |
If you want to validate a control's values but you don't see it as one of the choices on the Validation Patterns page, you can create your own. For example, you can create a custom pattern to values entered as percentages by following these steps:
- Select your control.
- Click the ellipsis next to Pattern in the properties of the control.
- On the Validation Patterns page, click Add Pattern on the toolbar.
- Name the pattern, give an example, and type in a validation message. The name must be unique.
- For the pattern use the following regular expression: [Value][%]
- Your new pattern should look like the following page.
Feature | Description | How to use it |
---|---|---|
Name | The name of the new pattern. This must be a unique name | Type a name |
Example | An example of a value that passes validation | Type an example |
Pattern | The regular expression for the pattern, e.g. [Value][%] | Type the regular expression |
Message | The message displayed if the value is not valid | Type the message |
To learn more about creating new patterns, look at the regular expressions for the existing patterns and search the internet for examples of expressions for common patterns. A more useful resource to help you define custom regular expressions is http://regexlib.com.