Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Here's a much better version, it doesn't show "#" in the field, and allows for a more normal feel (backspacing works now).

It also supports multiple phone patterns, the script currently has three, as you type more digits, it switches to a longer pattern. The three defined now are:

  ###-####

  (###) ###-####

  (###) ###-#### x####

Please give it a try.

PhoneFormat.fp7.zip

  • 4 weeks later...
Posted

Thanks. This is a great little script trigger for formatting phone numbers while typing.

I did run into a little snag though. The script has a small bug while entering a digit in the middle of the number (i.e. user mistakenly entered wrong number).

While trying to enter a digit in the middle of the number the cursor is immediately sent to the end of the phone number entry. This is fine if you only needed to enter 1 digit. What if you need to enter more than one digit or delete and replace a digit or 2. Every time you type, the cursor ends up back at the end of the text entry. So you have to take the mouse and click in the middle of the number to finish your correction.

If this bug could be fixed then the script would be perfect.

There is one other thing I would like to mention, this method doesn't work on global unrelated fields. But this is negligible.

Keep up the great work. :)

  • 3 weeks later...
Posted

Yeah, I see what you mean.

Try this one, its attempts to fix the selection point to match what it was before it changed the text.

Let me know if you notice any other problems too.

I wonder what would be involved in internationalizing this technique? Would this work? If the Country field is other than Canada or the U.S. then require require a country code as well as the region code and the local number.

I realize beyond North America country codes, region codes and even the local number can have variable lengths, making a standard formatting style and validation very difficult.

Posted

I really like what you've done here. But I confess that I liked the first version which showed (to the User) the masked format they were expected to enter. But I prefer all the enhancements to the second version. I would not dare attempt, nor would I find it respectful, to modify your code not that I could anyway.

Is it possible to have the best of both worlds?

LaRetta, don't be like that, anyone can change it anyway they like, and use it however they want.

Personally, I think the # pattern looks cheesy, but I can see your point about showing the user what's expected.

Here's the modified version, if you decide you don't want to see the patterns after all, change the $showPattern setVariable near the top of the script to False.

PhoneFormat.fp7.zip

Posted

Excellent work! With your permission I'd like to take it and apply it to my own database. Yet, I had trouble when I attempted to do so. I used the same script, not modifying anything, right clicked on the field and set it to trigger when modified, with the option script parameter set to:

Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName )

Yet, I get blanks when I try to enter a number in that field. I have attached my sample database and a screenshot. Any help from anyone would be appreciated. Seems like it should work, only difference I noticed was when I set my script trigger, a little red trigger icon appears in my field while it does not in your sample database. Thoughts?

screenshot.jpg

Phone.zip

Posted

You didn't copy over the custom function it used, so the script copier in FM helpfully commented out its usage in the script.

You would need to copy the custom function first, then copy the script. I dunno why I'm not seeing the red dot in my field though - I didn't do anything special with that, though I was hooked up to some of the other methods while I was debugging, then took them off.

Posted

not really contributing much, but underscore is a good placeholder vs #

I was really expecting that to suck also, but it does look nicer. :D

Here's a new copy, with the format character controlled in the script, you need to change the patterns to match it though.

Thanks for the suggestion.

PhoneFormat.fp7.zip

  • 5 months later...
  • Newbies
Posted

Love this phonenumber format. But I can't make it work in my file. how do I do it? I have the same problem that when I type in the field, it just shows blank. do I need FMP advanced to get this to work? How do I "copy over the custom function?"

  • 7 months later...
Posted

Shadow

Thanks for this. Can't get it to work on import. I'm only going to be importing the phone numbers. Am I setting the script triggers wrong?

I'm sure it's been done to death, but I'm guessing FM11 doesn't have phone numbers, etc., as formatting options?

Christopher

  • 3 years later...
Posted

Hi,

 

interesting matter, as a friend of mine asked me something similar to do . If this can help, searching the following link should help with worldwide phone number formats - at least with all countries members of ITU..!!.

 

http://www.itu.int/

 

hope this helps. :yep:

 

  • Like 1
  • 4 weeks later...
Posted

Hi,

To add another dumb question but I am not a programmer, I tried to use these samples onto a Db FMP12, but when I am closing the script window FMP tells me "Function not found" and highlighting " Value:formatCharAs".. I searched but did not find anything corresponding.

 

Any help, ?? What can i use to replace this "formatCharAs" ??

 

Thanks in advance

Posted

formatCharAs is a custom function in the demo db.  Since you have Advanced, you can go to File->Manage->Custom Functions... in the demo program and copy and paste it into your database.

 

If you didn't have FMA, you could not use this function, because you need Advanced to edit custom functions. FM can run them once installed by Advanced.

Posted

Not in this case, because this custom function is recursive (it calls itself). Calculations can't handle that.

Posted

OK Guys, 

Thanks a lot, now I am on the custom function case. A part from the FMP help, does it exist anything published about custom functions, I 've a creative mind, but I bet I need to know the rules before letting creativity running loose..!!

Posted

Yeaahhhh,

Thanks;

Perfect, let see if I get a brain overheat.. !!!

This topic is 4182 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.