Data Validation for Text & Number Together

li_Hua
New Member

Hi,
I would like to implement a container number in the app sheet. Is it possible to validate based on the first 4 characters are alphabets and the next 7 characters numbers and shows that entry is invalid if it does not meet the requirement?

Solved Solved
0 18 6,935
1 ACCEPTED SOLUTION

Unfortunately the expression will need to be much more complicated. So youโ€™ll need to use an expression like the below. I have tested it and it works well.

  • [_THIS] is a special variable that refers to the value, text in this case, of the current column.
  • The MID() function picks off each single character by its position in the text.
  • NUMBER() will return zero if the character is alphabetic.
  • NUMBER() will also return zero if the value is number 0 so we explicitly do not allow zero in the first 4 positions but DO allow โ€œ0000000โ€ for the last 7.
AND(
    LEN([_THIS]) = 11,
    AND(NUMBER(MID([_THIS],1,1))=0, MID([_THIS],1,1) <> "0"),
    AND(NUMBER(MID([_THIS],2,1))=0, MID([_THIS],2,1) <> "0"),
    AND(NUMBER(MID([_THIS],3,1))=0, MID([_THIS],3,1) <> "0"),
    AND(NUMBER(MID([_THIS],4,1))=0, MID([_THIS],4,1) <> "0"),
    OR(NUMBER(RIGHT([_THIS],7)) > 0, RIGHT([_THIS],7) = "0000000")
)

I would also recommend including a custom error message for when the format is invalid. An example might be:

"Correct format is 'xxx0000000' - 11 characters with 4 letters followed by 7 numbers"

Customer Message Goes Here:

Message Shows like this
2X_f_f975341cff63cfc8b570b8fba4a1319e5861ca15.png

View solution in original post

18 REPLIES 18