- Print
- DarkLight
- PDF
Description
Queues a validation block for an input object, conditioned on a specific value. When active, this block will prevent the user from continuing for the specified reason.
Input Parameters
Name | Type | Required | Description |
---|---|---|---|
token | Text | Yes | Input object token (i.e. [5]) |
reason | Text | Yes | Reason displayed to the user for being blocked |
value | Any | Yes | Value of input object that activates the block |
Returns
No return value.
Examples
// block the user if the value of input object [5] is 'Green'
user.blockIfValue("[5]", "Green is not allowed.", "Green");
// block the user if the value for input object [5] is missing
// note: consider using user.blockIfEmpty() instead
user.blockIfValue("[5]", "You must specify a valid color.", "");
Remarks
Validation is the process of making sure user inputs contain appropriate values. For example, if numbers are within an expected range or if required values are even entered at all.
Products that run your apps will typically support a feature where your app's user inputs are validated at some point in time (i.e. when the user tries to save their work).
You can hook into the validation process using the blocking functions.
- blockIfEmpty(...) - blocks user if a value is missing
- blockIfValue(...) - blocks user if a specific value is entered
- block(...) - blocks user (without a condition)
The runtime's validation process performs these steps when it's time to validate the user's inputs:
- The user performs an action that triggers validation (i.e. save).
- Your app's Ux.Validate script runs. This is your opportunity to add all the blocks you want via the available blocking functions. They are queued in the order they are added in your script.
- The runtime checks to see if any blocks are queued.
- If so, it displays a list of your blocking messages to the user and prevents them from continuing.
- If no blocks are queued, the user's action will proceed.
- All validation blocks are reset (cleared).