I know using validation for phone numbers is a bad idea, as it causes me headaches from the start.
I can format the way i want but which is the best way to ensure phone numbers are entered in as a 10 digit format.
I know using validation for phone numbers is a bad idea, as it causes me headaches from the start.
I can format the way i want but which is the best way to ensure phone numbers are entered in as a 10 digit format.
Are you able to just provide an example of what is acceptable? The below examples are all 10 digits but not sure if any should be rectified by your calculation and if so, rectified to what?
1234567894
123 456 7894
12 34 56 78 94
12345 67894
(123) 456 7894
0000000001
A simple check is: Length ( Filter ( TelephoneNo ; "0123456789" ) ) = 10
Yes to preserve the leading zeros, then you need to STORE into a field of type text not a field of type number.
You may "format" as (xxx) xxx-xxxx, or whatever format is preferred, once you have validated the length.
Validation is:
Length ( Filter ( TelephoneNo ; "0123456789" ) ) = 10
Auto-enter is something like this:
Let ( ph = Filter ( TelephoneNo ; "0123456789" ) ;
If ( Length (ph) = 10 ;
"(" & Left(ph;3) & ") " & Middle(ph;4;3) & "-" & Right(ph;4) ;
ph ) // don't change if not valid
)
HTH,
Beverly
I've just had this conversation on another thread... field validation is the best way to be 100% sure. But if that is causing you headaches then you could use a script trigger on object exit that performs the check and takes appropriate action. For instance something like:
Set Variable [ $ph; Value: Filter ( table::PhoneNo ; "0123456789" )]
If [not IsEmpty ( $ph ) and Length ( $ph ) = 10]
Set Field [ table::PhoneNo; $ph]
Else
Show Custom Dialogue [ "Hey fix your phone number up" ]
Go to Field [Select/perform; table::PhoneNo]
Yes to preserve the leading zeros, then you need to STORE into a field of type text not a field of type number.
You may "format" as (xxx) xxx-xxxx, or whatever format is preferred, once you have validated the length.
Validation is:
Auto-enter is something like this:
HTH,
Beverly