TEXT & NUMBER VALIDATION (Valid if)

Dear community,
I am working on an AppSheet App and I need to validate the entry of a CIF/NIF (fiscal number from Spain)

I'm trying to use the citated formula, but it doesn't work and I can't find the error 

The format to be validated is 9 characters long.
The first is a letter (A to Z) and is followed by eight numbers (0 to 9):

Example: A12345678 or B87654321 or D45781245

the valid_if formula in a Text column is:

AND(
          LEN([_THIS]) = 9,
          AND (NUMBER(MID([_THIS],1,1))=0, MID([_THIS],1,1) <> "0"),
          OR(NUMBER(RIGHT([_THIS],8)) > 0, RIGHT([_THIS],8) = "00000000")
        )

thanks in advance for the help.

0 1 147
1 REPLY 1

Please try a valid_if expression of 

AND(LEN([_THIS])=9,
ISBLANK(NUMBER(LEFT([_THIS],1))),
NUMBER(RIGHT([_THIS],8))>0,
ISNOTBLANK(EXTRACTHASHTAGS(CONCATENATE("#",LEFT([_THIS],1)))),
LEFT([_THIS],1)<>"_",
FIND(UPPER(LEFT([_THIS],1)),LEFT([_THIS],1))<>0
)

I believe  the expression will also take care of invalidating the data entry if

  1.        Special characters such as "*", "&" "%" etc. are entered as the first character
  2.        A lower case character such as "a" , "m" etc. are entered as first character
  3.       Any digits 0-9 are entered as first character
  4.      Any alphabets or special characters are entered as characters 2 to 9
  5.      If the length of the field is less than or greater than 9 characters

Please test well for multiple test cases. ๐Ÿ™‚

Top Labels in this Space