Author: Jonas Bilinkevicius
Is there a simple way of checking if all characters in a string are valid? For
example valid chars are: "ABCabcd123". If the string I want to check contains
"AA23c" it is valid, if it contains "AAY" it is invalid.
Answer:
This is one way to do it:
1 { ... }2 const3 ValidChars = 'ABCabcd123';
4 type5 EInvalidText = class(Exception);
6 var7 iCount: Integer;
8 begin9 for iCount := 1 to Length(Edit1.Text) do10 if Pos(Edit1.Text[iCount], ValidChars) = 0 then11 raise EInvalidText.Create('Invalid text entered.');
12 end;