Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 6th, 2009, 09:24 PM
gkaffka gkaffka is offline
Forum n00b
 
Join Date: Mar 2009
Posts: 9
Question Zip codes rule

Hey all. I am so new at this and if this is a silly or stupid post, please advise me on this. With that said. I need a rule that will do the following

If a zip code is 12345 and has no ZIP 4 then leave it as is... BUT if the zip code is 12345 and has a zip 4 of 6789 then add a dash 12345-6789. Does this make sense? If so anyone throw me a bone and help me out??? Just started and my job and this part is new to me.. Thanks so much for any help.

Reply With Quote
  #2  
Old April 7th, 2009, 06:23 AM
DSweet's Avatar
DSweet DSweet is offline
Senior Contributor
 
Join Date: Sep 2008
Location: Oberlin, Ohio
Posts: 252
Default Re: Zip codes rule

gkaffka,

If your zipcode is split into two fields with one being the normal 5 count and an additional field with the +4 count then use a rule such as this...
Code:
if (Trim(Field("plus4Code")) == "")  {
    return Field("zipcode");
}
else  {
    return Field("zipcode") + "-" + Field("plus4Code");
}
This would suffice for two separate entries for the zip code. However, if your zipcode is all one field then try this one...
Code:
if (Len(Field("zipcode")) = 5)  {
    return Field("zipcode");
}
else  {
    var zipLen = Len(Field("zipcode"));
    return Left(Field("zipcode"), 5) + "-" + Right(Field("zipcode"), (zipLen -5));
}
You do need to be careful since there really is no checking of the data that is done within these rules. You need to be sure to know your data and whether or not they are all valid zipcode items. Also, this rule is only valid for U.S. zipcodes and those that are similar in their make-up (5 or more digits without spaces). If you tried to use this rule with any Canadian zipcodes mixed in with the list the rule would still work correctly, but the output would not be valid according to the Post Office.
__________________
David A. Sweet
Variable Data Specialist
HKM Direct Market Communications
Windows 7, Acrobat 10.x
FusionPro Desktop and Server 10.0.26
Reply With Quote
  #3  
Old April 7th, 2009, 09:20 AM
gkaffka gkaffka is offline
Forum n00b
 
Join Date: Mar 2009
Posts: 9
Default Re: Zip codes rule

Thanks David.. That worked like a charm. I had to tweek to our name fields and it was right on. I am more of a graphics guy and I am now getting into the variable end. I was close, but missed a line or two..
Reply With Quote
Reply

Tags
dash, rules, zip code

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:01 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.