digit restriction

Is there an expression to restrict users to only enter certain amount of digits?

I’m making a phone number in 3 separate columns and Concatenate with VC

[phone1] & “-” & [phone2] & “-” & [phone3] = (eg; 010-1010-0101)

I want to make it so that only 3 digits are allowed in [phone1]

and 4 digits for [phone2] and [phone3]

valid-if

LEN([_THIS]) = 3

2 Likes

If those are number type columns, maybe valid_if as AND([phone1]<=999, LEN([phone1])=3)

AND([phone2]<=9999, LEN([phone2])=4)

AND([phone3]<=9999, LEN([phone3])=4)

Or simply LEN([phone1])=3 may work.

1 Like

seems like LEN() does not work with numbers :confused:

Also “000” does not work very well with Number either.

Here is an improved version. Not perfect but prevents non digits except for spaces, commas, periods (probably non alphabets…)

AND(
COUNT(EXTRACT(“NUMBERS”,[_THIS])) = 1,
LEN([_THIS]) = 3
)

1 Like

Modify the expressions to convert the number to text first then check the length like this:

...LEN(**TEXT(**[_THIS]**)**) = 4...

OR

AND([phone2]<=9999, LEN(**TEXT(**[phone2]**)**)=4)...

2 Likes

Thank you @WillowMobileSys . I had responded to @NCD from my mobile while away from desk and that type casting to text was inadvertently missing. Later @TeeSee1 took over and provided a solution that @NCD accepted. So I refrained from adding post for that typecasting correction.

Anyway, it is good for anyone reading the thread. Thank you again. Going forward I will also ensure that for the sake of correctness .

1 Like