Skip to main content
Participant
November 27, 2024
Answered

Conditional requirement field not working

  • November 27, 2024
  • 1 reply
  • 528 views

Thanks in advance. I can't figure out why this isn't working. If number field "Part 3-1-Quantity" is greater than zero, then date field "Part 3-1-Expiry Date" should be required.

 

var quantity = this.getField("Part 3-1-Quantity").value;
var expiryDateField = this.getField("Part 3-1-Expiry Date");

if (quantity > 0) {
expiryDateField.required = true;
} else {
expiryDateField.required = false;
}

This topic has been closed for replies.
Correct answer PDF Automation Station

Put it as a custom calculation script in any other text field except the two in the script.   It shouldn't be a mouse up action because the user has to enter the value then click the field.  Also, you would need to use event.target.value for the field's value.

1 reply

PDF Automation Station
Community Expert
Community Expert
November 27, 2024

It works for me.  Where do you have the script (field name and type - validation/calculation etc.)?

Participant
November 27, 2024

Thanks. I have it on the field "Part 3-1-Quantity", as an Action, Mouse Up, Run a Javascript.  Do i need to make the field "Part 3-1-Expiry Date" required or not required?

PDF Automation Station
Community Expert
Community Expert
November 27, 2024

Put it as a custom calculation script in any other text field except the two in the script.   It shouldn't be a mouse up action because the user has to enter the value then click the field.  Also, you would need to use event.target.value for the field's value.