R2i DotNetNuke® Forum

R2i wants you to have the opportunity to ask questions, post reviews, help others or just rant and rave about DotNetNuke® or any of the R2i Modules and Skins. Our team spends hour upon hour, day after day, working on custom DotNetNuke® modules and services; please feel free to ask us anything.
 
A method to store and format phone numbers
Last Post 01 Jan 1900 05:00 AM by . 0 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Informative
pauldesUser is Offline
Veteran Member
Veteran Member
Posts:1392

--
20 Sep 2007 02:09 PM  
By using the suggestions below, you can store your phone numbers that users enter in strict numeric only format, with no additional characters, then display it in a standardized way. I've found this useful for visual purposes and for displaying numbers automatically that can be used by external applications as hyperlinks, like Skype and iPhone.

When entering the phone number in your DB through insert or update, I use the following REPLACE directly in the SQL to get rid of spaces and characters. Adjust as needed.

REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(@Phone,'x',''),',',''),'.',''),')',''),'(',''),'-',''),'','')

This formatter will display a number as (XXX)XXX-XXXX where [phone] is your db column name. You can play with it to adjust for your purpose.
{IIF,[FORMAT,[phone],{LENGTH}]>10,[FORMAT,[phone],{MID:0,{MATH,[FORMAT,[phone],{LENGTH}]-10}}],}{IIF,[FORMAT,[phone],{LENGTH}]>7,([FORMAT,[FORMAT,[phone],{RIGHT:10}],{MID:0,{MATH,[FORMAT,[FORMAT,[phone],{RIGHT:10}],{LENGTH}]-7}}]),}{IIF,[FORMAT,[phone],{LENGTH}]>4,[FORMAT,[FORMAT,[phone],{RIGHT:7}],{MID:0,{MATH,[FORMAT,[FORMAT,[phone],{RIGHT:7}],{LENGTH}]-4}}]-,}[FORMAT,[phone],{RIGHT:4}]
ListX....makes you look brilliant, even though you're not.
You are not authorized to post a reply.

Active Forums 4.1
 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seatle, WA • 410.327.0007 • info@R2Integrated.com

Bookmark & Share Bookmark and Share