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

Compare two fields and show hidden field

New Here ,
May 18, 2017 May 18, 2017

I have two fields, one is calculated (text2) and the other has the user entering the data (text1). I want to compare the number entered to the calculated field. (The calculated field does not use the entered field in the calculation. Also, the calculation occurs prior to entries into text1) The entered number needs to be less than or equal to the calculated field. If it is not, I would like to un-hide a third text field (text3) - or I could use a popup alert. I do not want text3 to show until after something is entered into text1, meaning I don't want it to show before the user has a chance to enter a number.

I've read through an assortment of similar posts but can't seem to find an answer that will work. It is unclear to me if this should be a validation script, a custom calculation, or added to an action.

Any help would be greatly appreciated.

TOPICS
Acrobat SDK and JavaScript , Windows
307
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 ,
May 18, 2017 May 18, 2017

Place this JavaScript as a validation script in the Text1 field:

nText1 = event.value;

oText2 = this.getField("text2");

oText3 = this.getField("text3");

if (nText1.length > 0 && nText2.value.length > 0 && nText1 <= oText2.value) {

    // show Text3

    oText3.display = display.visible;

    // show alert

    app.alert("Hello world");

} else {

    // hide Text3

    oText3.display = display.hidden;

}


Acrobate du PDF, InDesigner et Photoshopographe
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 ,
May 19, 2017 May 19, 2017

I realize that I wasn't clear with what I was trying to do. I have a message field (CTAABInfoBox) that is displayed unless the entered value in "CTAAB" is > the calculated field "TotalBudget.GrandTotal". Here is what I have tried. It does not work properly.

var oCTAAB = this.getField("CTAAB");

var oFldTotalBudget = this.getField("TotalBudget.GrandTotal");

var oInfoBox = this.getField("CTAABInfoBox");

// test to see if entered CTAAB value < calculated TotalBudget.GrandTotal box

if (oCTAAB.value <  oFldTotalBudget.value)

{

    // show CTAABInfoBox

    oInfoBox.hidden = false; 

}

else

{

    // hide CTAABInfoBox

    oInfoBox.hidden = true;

}

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 ,
May 19, 2017 May 19, 2017
LATEST

- What does "not work properly" mean? Are there error messages?

- Where did you place the code?

- Do not use the hidden property. It's deprecated. Use the display property instead.

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