Skip to main content
christinay98009360
Participant
February 1, 2023
Answered

Return a zero value if nothing is in Year field

  • February 1, 2023
  • 1 reply
  • 494 views

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 has been closed for replies.
Correct answer try67

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

else event.value = 2022 - v1;

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 1, 2023

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

else event.value = 2022 - v1;

christinay98009360
Participant
February 1, 2023

Thank you kindly!  Worked 🙂