Hello,
is it possible to check if the phone number entered is good or not?
Example: If the number has 9 digits, I want to be able to display an error when the user enters a 7-digit number.
If so, how to implement the code?
Thank you
count the number of digits entered in a field
-
- Posts: 14
- Joined: September 22nd, 2016, 9:24 am
Re: count the number of digits entered in a field
If the phone number is entered as an alphanumeric variable you can use the length function to see how long it is.
-
- Posts: 1801
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: count the number of digits entered in a field
If the value is numeric, you can also calculate the base-10 log of the number, though you would check that it equals 8, not 9:
if int(log(PHONE_NUMBER)) <> 8 then
Re: count the number of digits entered in a field
Alternatively you can just test if the number is less than the smallest 9 digit number:
if PHONE_NUMBER < 100000000 then
This won't work if a phone number can start with zero but neither will the solution using log. If the number can start with zero you need to use alpha.