Skip to main content
Participant
August 16, 2024
Answered

Validating sum total with exactly two possible values, submission as a condition of invalid warning.

  • August 16, 2024
  • 1 reply
  • 580 views

I am trying to create a fillable form. There is an optional section where the user can pick percentages for each choice. I would like the invalid warning to pop up only on the conditions that: 1) The user enters a total that is neither 0 nor 100 and 2) The user tries to submit the form. Any help would be appreciated. Thank you!

This topic has been closed for replies.
Correct answer try67

Assuming the name of the total field is "Total", you can use this code as the Mouse Up script of your Submit button (instead of the current command, not alongside it!):

 

var total = Number(this.getField("Total").valueAsString);
if (total!=0 && total!=100) {
	app.alert("The total must equal 100 or 0 before the file can be submitted.",1);
} else this.mailDoc({cTo: "email@server.com"});

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 17, 2024

Assuming the name of the total field is "Total", you can use this code as the Mouse Up script of your Submit button (instead of the current command, not alongside it!):

 

var total = Number(this.getField("Total").valueAsString);
if (total!=0 && total!=100) {
	app.alert("The total must equal 100 or 0 before the file can be submitted.",1);
} else this.mailDoc({cTo: "email@server.com"});
Participant
August 17, 2024

Perfect, thank you!