Copy link to clipboard
Copied
I’m working in Acrobat DC
I’m creating a business card template. The fields are EmpName, Title, PhysicalAdd, Telephone, FAX, and EmailAdd.
My dilemma is with EmailAdd. The employee can choose to have their email address on the card or not. Below in span 5 you will see that I have added the
@HSa.co.merced.ca.us to the span. All the worker does is enter the first part of their email in the EmailAdd field. If the employee leaves the EmailAdd field
blank/empty, @HSa.co.merced.ca.us will still print on the card. How can I accommodate for an blank/empty EmailAdd field?
var spans = event.richValue;
spans[0] = new Object();
spans[0].text =
this.getField("EmpName").valueAsString + "\r";
spans[0].fontWeight = 700;
spans[0].textSize = 9;
spans[1] = new Object();
spans[1].text = this.getField("Title").valueAsString + "\r \r";
spans[1].fontWeight = 700;
spans[1].fontStyle ="italic";
spans[2]= new Object();
spans[2].text = this.getField("PhysicalAdd").valueAsString + "\r \r";
spans[3] = new Object();
spans[3].text = this.getField("Telephone").valueAsString + ", Ext. " + this.getField("Extension").valueAsString + "\r";
spans[4] = new Object();
spans[4].text = this.getField("FAX").valueAsString + "\r";
spans[5] = new Object();
spans[5].text = this.getField("EmailAdd").valueAsString + "@hsa.co.merced.ca.us";
event.richValue = spans;
Thank you
You can use this:
spans[5].text = this.getField("EmailAdd").valueAsString;
if (spans[5].text != "") spans[5].text += "@hsa.co.merced.ca.us";
Copy link to clipboard
Copied
You can use this:
spans[5].text = this.getField("EmailAdd").valueAsString;
if (spans[5].text != "") spans[5].text += "@hsa.co.merced.ca.us";
Copy link to clipboard
Copied
Thank you so much Bernd. I was trying to use an if statement but wasn't using the spans with it. Makes sense now.
Thanks again, it works perfectly!