Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
- 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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now