Hi,
I’m trying to create an input validation in a field so that it:
-
Only allows up to 6 numerical characters.
-
Contains between 2 and 4 alpha characters.
The field should be able to contain a combination of alpha and numerics. An appropriate entry for example would be CEG1234.
Thank you in advance for any help.
Subject: Alpha and numeric character lengths
If your requirements are …
Must have between 1 and 6 numbers
Must have between 2 and 4 characters
It’s a bit of a brute-force method, but this should work.
ALL := @Matches(string;“+{0-9A-Za-z}”);
N1 := @Matches(string;“{0-9}”);
N7 := @Matches(string;“{0-9}**{0-9}{0-9}{0-9}{0-9}{0-9}{0-9}*”);
C2 := @Matches(string;“{A-Za-z}{A-Za-z}*”);
C5 := @Matches(string;“{A-Za-z}{A-Za-z}{A-Za-z}{A-Za-z}{A-Za-z}”);
TEST := ALL & N1 & C2 & !( N7 | C5 );
ALL will detect if have only allowed characters.
N1 will detect if you have one number.
N7 will detect if you have 7 or more numbers
C2 will detect if you have two characters.
C5 will detect if you have 5 or more characters
TEST will ensure you have what you want, and don’t have what you don’t want. Remove all of the a-z if you don’t allow lower-case characters.
Subject: RE: Alpha and numeric character lengths
That gave me an error saying “Incorrect data type for operator or @function: Number expected.”
Subject: RE: Alpha and numeric character lengths
Yes, I had put ALL = instead of ALL := …
That’s what I get for entering untested code off the top of my head. And of course, you’ll need to do something with the TEST value.