Skip to main content
Participant
October 11, 2016
Question

How do you add some values if the field is empty?

  • October 11, 2016
  • 2 replies
  • 614 views

I am not familiar with Acrobat language. I'm trying to create a form fill with the W4 Form. There's a field where I have to add lines 3 and 4, but you can include amounts for credits from another worksheet. So I'm trying to sum the field 3 and 4 if the event value is empty, but if there're some other amount I want to add then I could add the manually and type them in the formfill.

This is the code I currently have:

var v1 = getField("W4D3").value;

var v2 = getField("W4D4").value;

// Set this field value equal to the difference if the field if empty

If (event.value == null)

{

event.value = v1 + v2;

}

PLEASE HELP!

This topic has been closed for replies.

2 replies

JoelGeraci_Datalogics
Participating Frequently
October 11, 2016

You probably want event.target.value to be sure you're getting the value of the field and not the value of the event but also, the value of an empty field is not null, it's an empty string. Your code might look like this...

if (event.target.value == "")

{

event.target.value = v1 + v2;

}

Participant
October 31, 2016

Thanks!! It worked !Excuse my lack of knowledge about javascript. I don't know anything but I have a project to do so I'm learning few things by googling it.