Craig,
The JavaScript rule below is from the printable KnowledgeBase.
They have a bunch of pre-written JavaScript rules you can use.

Copy and Paste the code below into a new rule



// This rule allows the user to enter a phone
// number in any format the want and then have
// FusionPro re-format the number according
// to your preferences.
// 
// To define the separator characters (between
// the area code, exchange, and number) simply
// type the character between the $1, $2, and
// $3 in the first six lines of code. By default,
// the separator character is a decimal (.)

var formatStyle01 = "$1-$2";                //simple 7 digit phone
var formatStyle02 = "($1) $2-$3";           //simple 10 digit phone
var formatStyle03 = "$1 ($2) $3-$4";        //10 digit phone starts with
1
var formatStyle04 = "($1) $2-$3 ext.$4";    //10 digit phone with
extension
var formatStyle05 = "$1 ($2) $3-$4 ext.$5"; //10 digit phone starts with
1 with extension
var formatStyle06 = "$1-$2 ext.$3";         //7 digit phone with
extension
var formatStyle07 = "$1-$2";                //7 digit phone can end in
non-digits
var formatStyle08 = "$1-$2 ext.$3";         //7 digit phone can end in
non-digits with extension
var formatStyle09 = "($1) $2-$3";           //7 digit phone can end in
non-digits starts with 1
var formatStyle10 = "($1) $2-$3 ext.$4";    //7 digit phone can end in
non-digits with extension starts with 1

var thisNumber = Field("Phone1");


/////////////////////////////////////////////////////
// DO NOT EDIT BELOW THIS LINE                     //
/////////////////////////////////////////////////////


return formatNumber(Trim(thisNumber));

function formatNumber(number01){

 var pattern01 = /^(\d{3})[^\w]*(\d{4})$/;         // 2201727 or
220-1727 or 220- 1727
 var pattern02 = /^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/;       //
8002201727 or 800-220-1727 or (800)220-1727 or (800) 220-1727
 var pattern03 = /^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})$/;
// 18002201727 or 1-800-220-1727 or +1 (800) 220-1727
 var pattern04 =
/^[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/;  //
800-220-1727 ext 12345 or (800) 220-1727 ext 12345
 var pattern05 =
/^\+?(\d{1})[\D]*(\d{3})[\D]*(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/; //
1-800-220-1727 ext 12345 or +1 (800) 220-1727 ext 12345
 var pattern06 = /^(\d{3})[\D]*(\d{4})\D*[x#n]\D*(\d+)$/;       //
2201727 ext 1234 or 220-1727 ext 1234 or 220- 1727 ext 1234
 
 var pattern07 = /^(\d{3})[^\d]*(\w{7})$/;         // 800LETTERS or
800-LETTERS or 800- LETTERS
 var pattern08 = /^(\d{3})[\D]*(\w{7})\D*[x#n]\D*(\d+)$/;       //
800LETTERS ext 1234 or 800-LETTERS ext 1234 or 800- LETTERS ext 1234
 var pattern09 = /^\+?(\d{1})[\D]*(\d{3})[^\d]*(\w{7})$/;       //
1800LETTERS or 1-800-LETTERS or +1 (800) LETTERS
 var pattern10 =
/^\+?(\d{1})[\D]*(\d{3})[^\d]*(\w{7})\D*[x#n]\D*(\d+)$/;  //
1-800-LETTERS ext 12345 or +1 (800) LETTERS ext 12345

 var patternEndExt = /(.)[x#n](.)/;
 var patternStart1 = /^[\D]*[1]/;

 if(number01.match(pattern01)){
  number01 = number01.replace(pattern01, formatStyle01);
  return number01;
 } else if(number01.match(pattern02)){
  number01 = number01.replace(pattern02, formatStyle02);
  return number01;
 } else if(number01.match(pattern03)){
  if (number01.match(patternStart1)){
   number01 = number01.replace(pattern03, formatStyle03);
   return number01;
  } else {
   number01 = number01.replace(pattern06, formatStyle06);
   return number01;
  }
 } else if(number01.match(pattern04)){
   number01 = number01.replace(pattern04, formatStyle04);
   return number01; 
 } else if(number01.match(pattern05)){
   number01 = number01.replace(pattern05, formatStyle05);
   return number01;
 }  else if(number01.match(pattern06)){
   number01 = number01.replace(pattern06, formatStyle06);
   return number01;
 } else if(number01.match(pattern07)){
   number01 = number01.replace(pattern07, formatStyle07);
   return number01;
 } else if(number01.match(pattern08)){
  if(number01.match(patternStart1)){
   number01 = number01.replace(pattern10, formatStyle10);
   return number01;
  } else {
   number01 = number01.replace(pattern08, formatStyle08);
   return number01;
  }
 } else if(number01.match(pattern09)){
   number01 = number01.replace(pattern09, formatStyle09);
   return number01;
 } else if(number01.match(pattern10)){
   number01 = number01.replace(pattern10, formatStyle10);
   return number01;
 } else {
  //return "no match any pattern";
  return number01;
 } 
}




-- 
Eric Carbone
Systems Administrator
MOR Printing, Inc.
Tel:  954-377-1197 x110
Cell: 954-931-7315
Fax: 954-582-5111
www.morprinting.com
 

-----Original Message-----
From: Craig Daters [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 12, 2007 2:30 PM
To: FusionPro Users Forum
Subject: [fusionpro] Change phone format rule

I need the "Change phone format rule" to give me this format option
"(123)
456-7890"

Note the space between the area code and number. I convert the XML rule
to
javascript, but I am not a regex kind of guy, so therefore I do not know
where to add the space. Can any one out there help me out with this one?

Craig D.

Craig Daters | Systems Administrator | [EMAIL PROTECTED]

West Press
1663 West Grant Road
Tucson, Arizona 85745-1433
(520) 624-4939 x208
(520) 624-2715 fax
www.westpress.com





--
Users of FusionPro Desktop have unlimited free email support. Contact Printable 
Support at [EMAIL PROTECTED]
--
View FusionPro Knowledge Base, FusionPro Samples at
www.printable.com/vdp/desktop.htm

--
You are currently subscribed to fusionpro as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]
--


--
Note:  All e-mail sent to or from this address will be received or otherwise 
recorded by the e-mail recipients of this forum. It is subject to archival, 
monitoring or review by, and/or disclosure to someone other than the recipient. 
Our privacy policy is posted on www.printplanet.com
--

Reply via email to