MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Need help with formatting phone number field

  Asked By: Adrianna    Date: Oct 20    Category: MOSS    Views: 36518

I'm working on a data view that reads and writes directly to a MSSQL table and
to a MOSS 2007 , using SPD 2007 .
My problem is that I have a field with a phone number but it currently displays
as '9999999999' and I need to mask it as '(999) 999-9999. I have the same
problem with a field for SSN. I already know how to do the validation to ensure
that the user enter the right data but the masking is my problem. I'd prefer
OOB functionality.
Can anybody help me out or point me in the right direction? I have search the
group and googled extensibly without finding an answer. Any help would be
certainly appreciated.



8 Answers Found

Answer #1    Answered By: Gobinda Navalagi     Answered On: Oct 20

Do you want to mask the input, or do you just need it formatted when it
displays? As I'm sure you know, the former is a bit more difficult. There
isn't really any OOB masking in SharePoint forms outside of InfoPath, but
you can achieve the desired effect using other available plug-ins. Take a
look at http://spdeveloper.net/tag/input-masks/ for a fairly simple jQuery

Answer #2    Answered By: Rose Silva     Answered On: Oct 20

I only need it formatted for display purpose. I tried the jquery solution but
that one is to modify the NewForm.aspx and mine is a dataview. I am not
knowledgeable enough to port the solution.

Answer #3    Answered By: Maegan Ellison     Answered On: Oct 20

Oh, well that's a bit easier. If you're using a DataView WebPart, then you
just need to build an XPath expression that breaks up the string. Assuming
that your field is called "Phone Number" (with a space), you would put this
into your DVWP:


Answer #4    Answered By: Yahaira Shannon     Answered On: Oct 20

Unfortunately I don't have an answer to your question - I'm a step behind in
your process. I'm trying to validate that the user enters the information
correctly - and sounds like you have already solved that problem and would you
mind sharing how you did that for SSN and phone numbers?

Answer #5    Answered By: Doris Leach     Answered On: Oct 20

There is a great webcast by Laura Rodgers that explains how to do it here:


Peter was very kind to tell me how to do the masking. However, I encounter
another problem: Some of the field in the existing data already were in the
(999) 999-9999 format and when I applied the formatting it messed those up. I'm
trying to add an if..then clause now but I can't get it to work.

Hope that page helps you.

Answer #6    Answered By: Sumitra 2004     Answered On: Oct 20

For data integrity, this should be a numeric field with no letters allowed.
I suggest creating a new column, doing a copy/paste from Datasheet to Excel,
cleaning the results, and then destroying/recreating the original column as
numeric, at which point you can paste the originals back in.

If that's not feasible, you could conceivably have a calculated column that
strips out the extra symbols.

If you're set on the IF conditional, then show us what you have and we can
help troubleshoot.

(IMO, the "pure data" approach is best because it avoids a lot of potential
user error -- dots, missing parens, etc.)

Answer #7    Answered By: Bhairavi Damle     Answered On: Oct 20

I'd certainly prefer the IF conditional approach
since I can't control how the data is entered and even if I clean the existing
data, it can happen again (I don't have access to the data entry side). The
statement I'm using is the following:

if (substring(@Phone,1,1) = '(') then

Both the condition and the concat statement work fine on their own but it's the
IF statemtent that I can't get right.

Answer #8    Answered By: Leeann Hull     Answered On: Oct 20

This is probably what you want:

<xsl:when test="substring(@Phone,1,1) = '('">
<xsl:value-of select="@Phone" />

It's not particularly elegant, but it will do the job. You could make it
slightly shorter by having two separate "if" blocks if you like.

Didn't find what you were looking for? Find more on Need help with formatting phone number field Or get search suggestion and latest updates.