Hi!
This is shorter but a bit more complex. Upon validation, the OnTextChange handler (or, in the second example, the OnClick handler) loops through each character in the string.
Since you are evaluating only one character of the password at a time - using the charAt(number) function - the conditions become much easier. The following condition tests whether the character at the first position (0) of the password is uppercase, where pwd is a local variable referring to the text in the password field:
If ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’ contains [[pwd.charAt(0)]]
The code, however, instead of using a hardcoded number in the charAt() function like 0, uses a variable that increases by one as it tests each letter, thus iterating through the whole password string. This “loop” also tests for the other required conditions.
This uses the Move By “function” call to do the actual evaluation. You could add length requirements to this “function.”
Here’s a live sample that requires uppercase, lowercase, numeric, and certain allowed special characters. It rejects the password if any illegal character is entered.
File: checkPassword.rp (85.8 KB)