How to Restrict the Lenght of Number Data Type

In India we have Pin Codes/Zip Code of 6 dights only. I want to restrict the entry to 6 digits only and the user should not be able to enter more or less than 6 digits and the data type is number not text. How do I do this?

I use LEN in text but it does not work in Number Data Type.

Please let me know. Thank you!!

Solved Solved
0 11 611
1 ACCEPTED SOLUTION

Alternatives (if user can enter numbers such as 010101, starting from zero which is accepted as 6 digit numbers.

Then only solution should be set the data type to text, and ensure the each chara is numbers.

If we restrict 6 diget all the time simply

And(len([_THIS])=6,
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],1),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],2),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],3),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],4),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],5),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],6),1))
)

In case we accept 4 to 6 digit for single column then valid if should be something like

AND(
len([_THIS])>=4,
len([_THIS])<=6,
IFS(
len([_THIS])=4,
And(
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],1),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],2),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],3),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],4),1))
),
len([_THIS])=5,
And(
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],1),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],2),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],3),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],4),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],5),1))
),
len([_THIS])=6,
And(
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],1),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],2),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],3),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],4),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],5),1)),
Contains({0,1,2,3,4,5,6,7,8,9},Right(Left([_this],6),1))
)
)
)

i not fully tested this expression, but should be alright.

I just simply assumed his requirement something line PIN code where 0001 0010 0100 is there, while people claim they are 4 digit numbers.

View solution in original post

11 REPLIES 11
Top Labels in this Space