Skip to main content
christinay98009360
Participant
Feb 1, 2023 11:01 PM UTC
Answered

Return a zero value if nothing is in Year field

Hi, I have a simple age calculator based on the year 2022 in one of my PDFs.  If there's no data present in the year field, it automatically shows "2022" in the text.  

 

This is my code:

 

// Get first field value

var v1 = getField("Year 1").value;

// Set this field value equal to the difference

event.value = 2022 - v1;

 

How do I get it to return a "zero" or no data, if the Year 1 field is left blank?

 

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Feb 1, 2023 11:07 PM UTC

if (v1=="") event.value = "";

else event.value = 2022 - v1;

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Feb 1, 2023 11:07 PM UTC

if (v1=="") event.value = "";

else event.value = 2022 - v1;

Translate
christinay98009360
Participant
Feb 1, 2023 11:09 PM UTC

Thank you kindly!  Worked 🙂

Translate