Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Conditional requirement field not working

New Here ,
Nov 27, 2024 Nov 27, 2024

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;
}

TOPICS
Create PDFs , General troubleshooting , How to , PDF , PDF forms
576
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Nov 27, 2024 Nov 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.

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2024 Nov 27, 2024

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 27, 2024 Nov 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 27, 2024 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 27, 2024 Nov 27, 2024
LATEST

Seems to be working. Thank you!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines