In this example, the respondent is requested to define a password. This operation will be performed on a single screen with two open-ended questions (password_open1 and password_open2). The value of the two open ended questions will need to match in order to allow the respondent to go through.
We'll perform the checks by using show message routings and displaying the error on screen.
All checks are based off the Askiascript syntax, of which the documentation can be found here.
The example QEX file can be downloaded here.
Check 1 : Passwords match
The error message will be triggered under this condition:
password_open1.value <> password_open2.value
Check 2 : Password length
In the example, I want a 7-digit password at least.
So the condition to use to trigger an error message will look like this:
password_open2.Value.length < 7
Check 3 : No space in password
In this example, I want to disallow usage of one single character: the space character.
There are various ways to achieve this, but I recommend using the replace method of AskiaScript 2.0.
The following script compares the password input with the same password after all spaces have been removed. If they are equal, it means that the password does not contain any space. If they are not equal, we need to display an error on screen. Here is the script that allows this:
password_open2.Value <> password_open2.value.Replace(" ","")
The replace method will look for spaces and replaces them by nothing, thus effectively removing all spaces.
Bonus: styling the input box
Change the following settings of the input to have it displayed as a password field:
Input type : password
Rows : 1
Will result in: