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

show and hide fields based on a date range

Explorer ,
Aug 13, 2017 Aug 13, 2017

Hello, I have been struggling with this for a while and can't find my exact situation out there.

How can I hide 2 text fields and 2 checkbox fields based on a particular date range?

I have a form that includes a date field,  after a certain date I don't want the fields to be available so I would like to hide those fields.

I tried the following, but I don't think I have the date syntax right. What am I doing wrong?

if(this.getField("Date").value >= "9/21/17"){   

this.getField("Text3").display = display.hidden;

}

else{

this.getField("Text3").display = display.visible;

}

Thank you so much in advance!

TOPICS
Acrobat SDK and JavaScript , Windows
4.2K
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

correct answers 1 Correct answer

Explorer , Aug 18, 2017 Aug 18, 2017

Ok, so I replaced the field name with a number value in the script and it all works great. THANK YOU!!!

Now the last part needed for this form is to incorporate 2 late fees on the last section - if after 9/21/2017 the late fee is 25% and if after 10/21/2017 the late fee is 50%. I am not sure how to add the second late fee to the script you gave me.

This is my attempt, it's working but not calculating the 1.5 correctly, it's multiplying 1.5 by the result of the first late fee (125) resulting in a t

...
Translate
Community Expert ,
Aug 19, 2017 Aug 19, 2017

It's an empty string. If the field is empty (that is, has not value) we should not try to convert it to a Date field, because doing that will result in the current date, which is incorrect.

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
Explorer ,
Aug 19, 2017 Aug 19, 2017

Is valueAsString strictly Acrobat JavaScript?

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 ,
Aug 20, 2017 Aug 20, 2017
LATEST

It's a property of the Field object, which only exists in the Acrobat JS API, so yes.

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