Phone number mask in a DataView WebPart (DVWP)

Posted by PeterBrunone on ASP.net Weblogs See other posts from ASP.net Weblogs or by PeterBrunone
Published on Tue, 07 Dec 2010 16:34:00 GMT Indexed on 2010/12/08 5:39 UTC
Read the original article Hit count: 231

This came up today on the [sharepointdiscussions] list.  A user needed to display a read-only field in a phone number format; it's pretty simple, but it may be just what you need.

Assuming your list item contains a field called "Phone Number" (with a space), the following XPath will give you a number in the classic US telephone format:

<xsl:value-of select="concat('(',substring(@Phone_x0020_Number,1,3),')',substring(@Phone_x0020_Number,4,3),'-',substring(@Phone_x0020_Number,7,4))" />

If you need to mask an input, try this jQuery solution.

© ASP.net Weblogs or respective owner

Related posts about sharepoint

Related posts about SharePoint Designer