Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Subtract a value from another field

Avatar

Avatar
Validate 1
Level 1
esdigrap
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
esdigrap
Level 1

Likes

0 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
esdigrap
Level 1

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
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,686 posts

Correct Reply

490 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,686 posts

Correct Reply

490 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
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