Subtract a value from another field

Avatar

Avatar

esdigrap

Avatar

esdigrap

esdigrap

20-02-2020

Good day to all
I'm still new in creating forms with codes. I'm working on a school project and this one is a bit complicated. I have a form with 100+ fields (all of them are mandatory IF the previous is filled in and some have validation patterns) and a bunch of signature fields. Now, my problem is I want to prevent anyone from printing the form if incomplete (plus the fields with default values). So an idea came, what if I put a invisible text field with initial value of 150 and when the user put a data (!= null) on a field(s), the value of the invisible text field will become 149 and so on.

The real problem is I test the below screenshot (I don't know how to attached pdf files) and whenever I change the value on the first text field, the value of the invisible text field is continuously dropping down.


How to prevent that or is there any workaround?

 

My simple code for the exit event of the first text field:

 

if (this.rawValue == "Value" )
{
form1.page1.Count.count.rawValue - 0;
}
else if (this.rawValue != null)
{
form1.page1.Count.count.rawValue -= 1;
}
else
{

}

The field with initial value of 7 is the "count" in a subform "Count"

Capture.PNG

and my prePrint code is:

 

if (xfa.resolveNode("#subform.count").rawValue > 1)

{

xfa.event.cancelAction = true;
xfa.host.messageBox("Please complete the form");

}

else
{
xfa.event.cancelAction = false;
}

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

22-02-2020

You don't need any scripting or counters at all to prevent the printing. 

Simply add a <validate>-element with the value "prePrint" under the element <config><present> in the XML source view.

radzmar_0-1582378777968.png