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.
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.
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)
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
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?
123 456 7894
12 34 56 78 94
(123) 456 7894
A simple check is: Length ( Filter ( TelephoneNo ; "0123456789" ) ) = 10
Sorry yes setting up filters etc i can to to remove the ()+ and spaces, getting it to ensure it is length of 10 and prompting client to correct if not.
So preferred format would be including area code 08912345555 so it is same as mobile 0416555555.
You're showing an 11 digit and a 10 digit number
use three fields with appropriate filtering and validation.
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]
Show Custom Dialogue [ "Hey fix your phone number up" ]
Go to Field [Select/perform; table::PhoneNo]
Twilio has a free phone number format validation API
Pass any number and country code and if the number can be interpreted you'll get the number back the national format and the international (E.164) format.
Yes using the twilio to send sms reminders. Getting it to add the + is was easy but it still requires the 61 for australia international code.
Thank you Bev, the length is what i was looking for, already sent them as text instead of numbers so it would display correctly.
Retrieving data ...