Skip to main content
Inspiring
July 6, 2022
Answered

IfText1 is between a range of number, then enter this into Text2

  • July 6, 2022
  • 4 replies
  • 1080 views

I work for a financial institution and I'm trying to create a form for our automatic payments. If Text1 (aka the loan number) is beween 0800 and 0899 OR 8000 and 8999 OR 0900 and 0999 OR 9000 and 9999 then I need Text2 to be visible and say "Variable Rate Payment".

 

 

This topic has been closed for replies.
Correct answer try67

OK, then you can use this code as the custom Calculation script of Text2:

 

var v = Number(this.getField("Text1").valueAsString);
if ((v>=800 && v<=899) || (v>=8000 && v<=8999) || (v>=900 && v<=999) || (v>=9000 && v<=9999))
	event.value = "Variable Rate Payment";
else event.value = "";

4 replies

JR Boulay
Community Expert
Community Expert
July 12, 2022

Can you share (part of) this document?

Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
Community Expert
July 8, 2022

Be sure that it uses a "Number" format and place this script as a validation script in Text1:

 

var oFld = this.getField("Text2");
if ((event.value >= 800 && event.value <= 899) || (event.value >= 8000 && event.value <= 8999) || (event.value >= 900 && event.value <= 999) || (event.value >= 9000 && event.value <= 9999)) {
oFld.value = "Variable Rate Payment";
oFld.display = display.visible;
}
else {
oFld.value = oFld.defaultValue;
oFld.display = display.hidden;
}

Acrobate du PDF, InDesigner et Photoshopographe
Inspiring
July 11, 2022

It doesn't appear that this is actually doing anything. It's not showing or hiding the box, and it's not putting in the text. I have entered the formula in the "run custom validation script" box on the validate tab. It's not giving me an error or anything - it's just not working. Any suggestions?

try67
Community Expert
Community Expert
July 8, 2022

And if it's not?

Inspiring
July 11, 2022

If it's not one of those numbers or any in between then I need Text2 to just be blank.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 11, 2022

OK, then you can use this code as the custom Calculation script of Text2:

 

var v = Number(this.getField("Text1").valueAsString);
if ((v>=800 && v<=899) || (v>=8000 && v<=8999) || (v>=900 && v<=999) || (v>=9000 && v<=9999))
	event.value = "Variable Rate Payment";
else event.value = "";
Amal.
Legend
July 8, 2022

Hi there

 

Hope you are doing well and sorry to hear that.

 

The workflow you are trying to achieve is possible using JavaScript. For more information please check the help pages listed below:

https://acrobatusers.com/tutorials/javascript_console/

https://helpx.adobe.com/acrobat/using/applying-actions-scripts-pdfs.html

 

Hope it will help

 

Regards

Amal