See also: fvFormatPhone

Function used to format a phone number according to a specific format.

Syntax

JSV_fsFormatPhone(expP [, expM])

Prototype

n/a

Returns

The fsFormatPhone function returns the phone number formatted in accordance with the designated format.

Parameters

The fsFormatPhone function uses the following arguments.

Argument Description
expP The phone number.
expM Optional. Mask used to format the phone number where 'X' represents a single digit. Default format is (XXX) XXX-XXXX.

Remarks

n/a

Dependencies

JSV_isWhitespace, JSV_stripCharacters, JSV_occurs

Example

The following lines of code

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
function fmtPhone() {
    document.TestForm.PhoneNo.value = 
        JSV_fsFormatPhone(document.TestForm.PhoneNo.value, document.TestForm.Mask.value);
}
</SCRIPT>

<FORM NAME="TestForm">
Phone: <INPUT TYPE="Text" NAME="PhoneNo" VALUE="6072341234" SIZE="16" MAXLENGTH="32">
Mask: <INPUT TYPE="Text" NAME="Mask" VALUE="(XXX) XXX-XXXX" SIZE="16" MAXLENGTH="16">
<INPUT TYPE="Button" NAME="FmtFone" VALUE="Format Phone" onClick="fmtPhone();">
<INPUT TYPE="Reset">
</FORM>

produce

Phone:
Mask: