Jump to content

Here's Another CF Phone Format


This topic is 6680 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Here's a Custom Function that formats phone numbers. It removes a leading '1' and handles 10 and 7 digits. If the format is incorrect (not 7 or 10), it changes the text color to red as an indicator for the user. It requires 1 function parameter called 'Phone':

Let (

[ num = Filter ( Phone ;"0123456789" );

num = Case(Left(num;1)= "1"; Middle(num;2;20); num);

len = Length(num) ];

Case( len = 10; TextColor(Left( num; 3) & " " & Middle( num; 4; 3) & "-" & Middle( num ;7;4); RGB(0;0;0)); // with area code

len = 7; TextColor( Left( num; 3) & "-" & Middle( num;4;4); RGB(0;0;0)); // without area code

TextColor(num; RGB(255;0;0) ) ) // wrong length so make text red

)

See my other posting in this forum 'This is for Comment' for more flexible methods.

Steve

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 weeks later...

Calling a foreign country from within the USA will always start with "011" (except country codes 808 and 809, Dominican Republic and Midway, respectively) but the country's code, which follows 011, can be from 1 to 5 digits long. I believe you'd need a database of all country codes to reference in your calc to make it work internationally.

Hope this helps!

Link to comment
Share on other sites

This topic is 6680 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.