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 ?