The Shadow Posted January 7, 2009 Posted January 7, 2009 A phone number formatter, that reformats as you type, give it a try (FM 10 only)! [ This is just a sample, so I'm using American format, I realize not all phone numbers look like this. ] FM10Test.fp7.zip
The Shadow Posted January 9, 2009 Author Posted January 9, 2009 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
raymanj Posted February 1, 2009 Posted February 1, 2009 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. :)
The Shadow Posted February 2, 2009 Author Posted February 2, 2009 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. PhoneFormat.fp7.zip
sandyinlet Posted February 17, 2009 Posted February 17, 2009 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.
The Shadow Posted February 18, 2009 Author Posted February 18, 2009 The script has multiple patterns at the top of it that should easily be localizable, you should take a look at it and give it a try.
The Shadow Posted February 19, 2009 Author Posted February 19, 2009 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
Jredeemer14 Posted February 23, 2009 Posted February 23, 2009 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? Phone.zip
Genx Posted February 24, 2009 Posted February 24, 2009 not really contributing much, but underscore is a good placeholder vs #
The Shadow Posted February 24, 2009 Author Posted February 24, 2009 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.
The Shadow Posted February 24, 2009 Author Posted February 24, 2009 not really contributing much, but underscore is a good placeholder vs # I was really expecting that to suck also, but it does look nicer. 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
Newbies rllewis Posted August 19, 2009 Newbies Posted August 19, 2009 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?"
Newbies rllewis Posted August 25, 2009 Newbies Posted August 25, 2009 Hi LaRetta, Just double checking you got the file I emailed you. Thanks.
HunterBoss Posted April 20, 2010 Posted April 20, 2010 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
Capt JB Posted May 13, 2013 Posted May 13, 2013 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. 1
Capt JB Posted June 10, 2013 Posted June 10, 2013 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
doughemi Posted June 11, 2013 Posted June 11, 2013 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.
Rick Whitelaw Posted June 11, 2013 Posted June 11, 2013 But even without Advanced it can be used as a calculation, no?
doughemi Posted June 11, 2013 Posted June 11, 2013 Not in this case, because this custom function is recursive (it calls itself). Calculations can't handle that.
Capt JB Posted June 11, 2013 Posted June 11, 2013 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..!!
doughemi Posted June 11, 2013 Posted June 11, 2013 Only about 47,000 hits on a Google search for "Filemaker Custom Functions". Before you re-invent the wheel, check out http://www.briandunning.com/filemaker-custom-functions/
Capt JB Posted June 11, 2013 Posted June 11, 2013 Yeaahhhh, Thanks; Perfect, let see if I get a brain overheat..
Recommended Posts
This topic is 4455 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 accountSign in
Already have an account? Sign in here.
Sign In Now