MeeshKB Posted July 23, 2012 Share Posted July 23, 2012 Hi all. I have what I think must be a very common question, but I have not been able to find an answer despite searching the forums. When building business card variable forms, I have a couple of fields which are sometimes empty, but when there is a value in them, I require a character before them. For example professional designations, which require a comma and a space before them. So the text reads Jon Doe, C.E.T. But of course if Jon Doe doesn't have a designation, I don't need the comma. I'm sure this is javascript 101, but I haven't been able to find the answer. Could someone be so kind as to point me in the right direction? Thanks so much. Michelle Link to comment Share on other sites More sharing options...
ThomasLewis Posted July 23, 2012 Share Posted July 23, 2012 If you are building this out in the Variable Text Editor you can make a simple JavaScript rule like this: if (Field("designation").length > 0) return ", " + Field("designation"); else return ""; This checks the amount of characters in the field for the designation and adds the comma. If there are none then it returns nothing. Then you can simply add the rule after the name field in the Variable Text Editor. Link to comment Share on other sites More sharing options...
MeeshKB Posted July 23, 2012 Author Share Posted July 23, 2012 Thank you so much. Of course minutes after I posted this I stumbled upon the variable text editor and I am now working at this very thing. Thanks again for your prompt reply. It's much appreciated. ETA: And it's working brilliantly. Thanks again! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.