|
Comments
|
Today's Top SOA Links
ColdFusion News Desk PhoneFormatter.cfc 1.0 in ColdFusion
I typically store phone numbers in one field instead of using a separate field for each part of a phone number
By: Steve Bryant
Jun. 8, 2007 09:30 AM
I typically store phone numbers in one field (instead of using a separate field for each part of a phone number). While this usually works quite well, I have discovered that it can cause issues when I want a phone number to display in the same format regardless of how it was originally entered. This is relatively easy to do if you handle it as the data comes in, but if you don't (either as oversight or because the data comes from outside the system) then it is a more difficult task. I created PhoneFormatter to handle this task. Actually, it can handle formatting the data on an individual string or on a field across a whole table. PhoneFormatter does require DataMgr. It also requires you to pass in the format you want to use for the phone number (using zeros as place-holders for digits). You should also pass in a default area code for numbers that don't have one. So the arguments for the init() method are:
To format a single phone number, pass it to the fixPhoneNumber() function (optionally passing in an area code as a separate argument). To format every row for one field in a table, use the fixPhoneNumbers() method.
PhoneFormatter may not solve a problem that you have, but if it does it can certainly be useful. It is open source and free for any use. Feel free to download PhoneFormatter and try it out. Reader Feedback: Page 1 of 1
Your Feedback
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||