Validation rules

Description

Specify rules to test if the data in this field is valid. By default, only dirty fields are validated. You can specify that all fields should be validated in Update Settings, Edit Properties. If this field is a Repeating Section, see the setting in the Repeating Section for 'Validation - field option' and 'Validation - row option'.

images/vr.png

Field Validation Settings

General
 
Enable rules

Specify if this field has validation rules

Require value

Require a value to be entered

Text Format
 
Allow letters

Allow letters (A-Z).

Allow whitespace

Allow whitespace characters (spaces, tabs, line feeds).

Allow digits

Allow numeric digits (1234567890).

Allow special characters

Allow special characters such as ~!@#$%^&*()_+, etc.

Use 'Simple mask'

Require value to match the simple mask specified below.

Regular Expression

Validate using a regular expression.

Custom Error Message

Enter your custom error message here. If a custom error is defined, the built-in validation error messages will be replaced by this text.

Data length
 
Validate length

Require data to meet length requirements as specified below.

Minimum Length

The value must be greater than or equal to this length. Set to 0 for no minimum length.

Maximum Length

The value must be less than or equal to this length. Set to 0 for no maximum length.

Custom Error Message

Enter your custom error message here. If a custom error is defined, the built-in validation error messages will be replaced by this text.

Data value
 
Validation expression type

Select 'None', 'Simple expression', or 'Custom expression'

Must be

Used with simple expressions to add a logical statement.

Value

The value to be used in a simple expression.

Custom Expression

Enter an expression that must evaluate to a True Value. Use 'CurrentValue' as a placeholder for the current control's value. When constructing the Validation Expression, remember that 'CurrentValue' is always a character variable (even if it contains a date or numeric value). Therefore, you may need to use functions in your validation expression to convert 'CurrentValue' to the appropriate data type.

Custom Error Message

Enter your custom error message here. If a custom error is defined, the built-in validation error messages will be replaced by this text.

Cross-file Validation
 
Data source

Specify if the data comes from a local DBF file or from an AlphaDAO data source.

Table name

The table to reference in the DBF file.

Field name

The field to reference in the referenced table from the DBF file.

Use saved connection string

Use saved connection string. This setting appears when the 'Data source' is set to 'AlphaDAO'.

AlphaDAO Connection string

Specify the connection string. This setting appears when the 'Data source' is set to 'AlphaDAO'.

Table

The AlphaDAO table to reference.

Field

The field to reference in the AlphaDAO table.

Value must

Used when the Data source is set to DBF. Specify that the value must or must not exist in the specified table.

Custom Error Message

Enter your custom error message here. If a custom error is defined, the built-in validation error messages will be replaced by this text.

Cross-File Validation

Cross-file validation allows you to return a validation error message after user input has been compared against an existing SQL or DBF database on the server. In order to carry out the validation set the [Immediate validation] property to be 'Client-side and Server-side', or follow the guide below.

  1. In the UX Builder, on the UX Controls page, open the 'Data Controls' menu. Click on the [TextBox] option to add a textbox to the component. Give this textbox the name and label of 'country'.

    images/vru2.png
  2. Highlight the textbox control. In the properties list on the right click the dropdown next to the 'Immediate validation' property in the 'Field Properties' section. Select the 'Client-side and server-side' option.

    images/vru3.png
  3. Click the [...] button next to the 'Validation rules' property.

    images/vru4.png
  4. Check the 'Enable rules' checkbox in the 'General' section.

    images/vru5.png
  5. Leave the 'Text Format' section of the 'Field Validation' dialog set to its defaults.

    images/vru6.png
  6. In the Cross-file Validation settings click the dropdown next to the 'Data source' setting and select 'AlphaDAO'.

    images/vru7.png
  7. If you already have a saved connection string to the 'Northwind' database then check the 'Use saved connection string' checkbox. If you do not have a saved connection string you can build one by leaving this box unchecked and then clicking the [...] button next to the 'AlphaDAO Connection string' property.

    images/vru8.png
  8. Set the 'Connection string name' property to 'Northwind'.

    images/vru9.png
  9. Set the 'Table' property to 'Consumer'

    images/vru10.png
  10. Set the 'Field' property to 'Country'.

    images/vru14.png
  11. Set the 'Value must' property to 'Exist'

    images/vru11.png
  12. Next to the 'Custom Error Message' setting type a message to be displayed like the one below and click OK.

    There are no customers in this country.
    images/vru12.png
  13. Run the component in Live Preview. Type a fictitious name into 'country' field. Click off of the textbox and Alpha Anywhere will perform an Ajax callback comparing the data you entered against the Customer table's 'Country' field. You should receive an error message.

    images/vru13.png
  14. Follow the same procedure for a country that you know to exist in the field, like 'Spain'. You should receive no error message.

    images/vru15.png
    The customers table does not contain a complete list of countries.

See Also