ThatÂ’s not really a global standard but if you must use it and force it...
Id put it in the database as 9999999999

Then use CF to format it for display.

'(' & left(phone, 3) & ') ' & mid(phone, 4, 3) & '-' & right(phone, 4)

That's dependent on you ensuring the number is 10 digits only. No more, no
less.

The further you get into a project, the more apparent that it normally
becomes that you should always leave user inputted data exactly as the user
entered it.

If you want to force the way THE USER enters something into the database,
then make them input it that way by checking it against a regular
expression.

\(\d{3}\) \d{3}-\d{4}

That should work for your format.

-or-

Make sure YOU can enter it the way you want/need with what they've given you
or don't enter it at all.

1) strip anything but numbers
2) check to see if it is 10 digits only (no more no less)
 - if so format it
 - else display a message

<cfset phone = rereplace(phone, "[^0-9]", "", "all") />
<cfif len(phone) is 10>
#'(' & left(phone, 3) & ') ' & mid(phone, 4, 3) & '-' & right(phone, 4)#
<cfelse>
Only 10 digit numbers are allowed.
</cfif>

..:.:.:.:.:.:.:.:.:.:.:.
Bobby Hartsfield
http://acoderslife.com
 

 


-----Original Message-----
From: Steve LaBadie [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 04, 2006 12:05 PM
To: CF-Talk
Subject: Phone Number Mask

When I created my test database I set up a phone number mask (999)
999-9999.  The data entered directly displays perfect.  When I insert a
new record from the admin panel the phone number show as 999-999-9999.
What do I need to do with the admin panel so number display properly?

 

Steve LaBadie, Web Manager
East Stroudsburg University
200 Prospect St.
East Stroudsburg, Pa 18301
570-422-3999
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> 
http://www.esu.edu <http://www3.esu.edu> 

 





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://ad.doubleclick.net/clk;56760587;14748456;a?http://www.adobe.com/products/coldfusion/flex2/?sdid=LVNU

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:262785
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to