Only allow numbers and certain length in Appsheet text box

I want to restrict user to enter a 5 digits number in text field, since I need to check the length of input I cannot use Number as the data type. The data contains leading zero so I cannot not use text([Field]) to convert the number to text for processing.

I use the formula AND(Number([Field]) <> 0, Number([Field])<>"", Len([Field])=5)

However, when I input "abcde" it let me go through, but I checked with the test result, the formula actually returns False, then I simplify the formula to just Number([Field]) <> 0, the result is the same. False but let me pass through.

why it allow to pass with the valid_if is False? Did I do it in a wrong way? 

Please help, thanks in advance.

0 2 743
2 REPLIES 2

You can try this

AND(
  ISNOTBLANK([FIELD]),
  LEN([FIELD]) = 5,
  NOT(CONTAINS([FIELD], " ")),
  LEN(TEXT(NUMBER([FIELD])))>0
)

You can edit it to your needs by adding more or less conditions
the trick is the last LEN statement.

I change Number([Customer Code])<>0 to Number([Customer Code])>0 and it works....both cases return false, but only the latter one work, I think <> operator is somewhat ignored

Top Labels in this Space