0
votes

I want only one to 5 characters in a field. Sometimes, the field can be empty too. It should be allowed. But if there is a value in the field, then that should be of digits and/or letters.

I have written the following validation rule.

NOT(REGEX(MyField , "[a-zA-Z0-9]{5}"))

But this does not allow empty fields and not even the ones that are of less than 5 in length. Can someone help with this ?

1

1 Answers

0
votes

You're 95% of the way there, just add a range to the characters of 0-5

NOT(REGEX(MyField , "[a-zA-Z0-9]{0,5}"))