This question came from a post I responded to and got me thinking that this was something that may be required at times, so I came up with the model in this blog. It may have other application as well as the Text Box example.
Firstly do a Collection of all special characters (you can do this at Screen OnVisible) by using their ASCII value ranges
ClearCollect(
colChar,
ForAll(
Sequence(15),
{FieldNo: Char(32 + Value)}
),
ForAll(
Sequence(7),
{FieldNo: Char(57 + Value)}
),
ForAll(
Sequence(5),
{FieldNo: Char(90 + Value)}
),
ForAll(
Sequence(4),
{FieldNo: Char(122 + Value)}
)
)
this puts 31 Special Characters into the collection under the field FieldNo. There may be some you want to allow such as underscore _ (95) so you would have to adjust the below to suit.
Below is a gallery (with wrap at 4) showing the characters
Now put this on the OnChange of the Text Box
ForAll(
colChar,
If(
FieldNo in Self.Text,
Collect(
colError,
{CharError: true}
);
Reset(Self)
)
)
NOTE - I had to use a Collection here as a Variable cannot be set inside a ForAll() statement.
Put this on the OnSelect of the Text Box - you could also in addition put this at Screen OnVisible
Clear(colError)
Now put a Label (this is the warning message) on the screen with this as the Text
"Do not use characters " & Concat(
colChar,
FieldNo & ""
) & " here"
and this as the Visible
First(colError).CharError
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.