Page tree
Skip to end of metadata
Go to start of metadata

Introduced in



Description:This script allows the validation of dialog input via restrictions defined in the dialog itself.

In order to validate a complete dialog, the validator should be called at load time, e.g.

class MyDialog {
  idd    = -1;
  onLoad = "['MyDialog', _this select 0] execVM '\vbs2\ui\Data\Scripts\inputValidator.sqf'";

Each control in this dialog that should be validated then needs a special sub-class defined (named "Validation"). This contains several properties that defined the restrictions and response options:

  • type: String - Validator type . Can be
  • allowEmpty: Boolean - Whether empty strings are allowed (only applies to type 'number' or 'code').
  • allowDecimal: Boolean - Whether decimal points are allowed (only applies to type 'number').
  • allowedValues: Array - Numbers which are allowed exclusively (only applies to type 'number').
  • excludedValues: Boolean - Numbers which are not allowed (only applies to type 'number').
  • limitChars: Number - Maximum number of characters allowed. Any further characters are removed. (default: 0=unlimited)
  • scriptedCondition: String - Condition that must evaluate true for this field to be considered valid. Validated control is passed as _this. (default: true)
  • failColor: Color - The text color the control gets changed to if the validation fails. (default: same as colorText)
  • disableControls: Array - Array of IDCs of controls that should be disabled if the validation fails. (default: [])

Since V3.4, the following options are also available:

  • allowedChars: String - List of characters that can be entered. (default: all)
  • excludedChars: String - List of characters that cannot be entered. (default: none)
  • filterCaseSensitive: Boolean - Specifies whether 'allowedChars' and 'excludedChars' comparison is case-sensitive. (default: false)
  • onSuccess: String - Code to execute when validation succeeds. Validated control is passed as _this. (default: nothing)
  • onFail: String - Code to execute when validation fails. Validated control is passed as _this. (default: nothing)
  • limitEventTrigger: Boolean - onSuccess and onFail will only trigger when the validation status changes. (default: true)
  • ignoreDisabled: Boolean - When false controls will be validated, even when they are disabled. (default: true)
class Input1 : RscEdit {
  idc = 111;
  x = .4; y = .4; w = .1; h = .1;
  class Validation {
    type = "number";
    failColor[] = {1,0,0,1};
    disableControls[] = {1234};


Syntax:[dialogName, display] execVM "\vbs2\ui\Data\Scripts\inputValidator.sqf"
  • dialogName: String - Class name of dialog to validate.
  • display: Display - Display that is being validated.
Return Value:Nothing

Alternative Syntax

Syntax:control execVM "\vbs2\ui\Data\Scripts\inputValidator.sqf"
  • control: Control - Specific control to validate. This function can only be used after the whole dialog has been set up with a validator (as per the first syntax). While manually entered input will automatically be validated in such a form, input defined via ctrlSetText is not, and for those situations this alternative syntax is available.
Return Value:Nothing



Call validator on dialog load (defined in description.ext):

onLoad = "['TestDialog', _this select 0] execVM '\vbs2\ui\Data\Scripts\inputValidator.sqf'";

Validate a single control (e.g. from a script):

_control1 execVM "\vbs2\ui\Data\Scripts\inputValidator.sqf"

Demo mission:

Additional Information

See also: fn vbs validateNumber, fn vbs validateCode