Trying to create a JavaScript code for conditional logic on a text box formatted as NUMBERS
Hi,
I'm trying to create a script that will change the fill color of a text box depending on the value. The text box is formatted to numbers only, with no decimals. The text has transparent fill and border by default and will be empty by default.
The desired behavior is if text box value = 0, 1, 2, or 3 then change fill color to red and border color to blue. If blank or > 3 then fill and border color should be transparent. The problem I'm having is that if the text box is blank, it applies the red fill color/blue border color. I have the trigger as On Focus and again On Blur, trying to account for what our staff may potentially do when working with this document. My company has ADOBE ACROBAT STANDARD DC.
Any guidance would be appreciated!
My code so far:
var nRemSup = this.getField("Rm Supply text box 1").value;
var fld = this.getField("Rm Supply text box 1");
if((nRemSup < 4) && (nRemSup >= 0)) {
fld.fillColor = ["RGB", 1,0,0];
fld.strokeColor = ["RGB",0,0,1];}
else if(nRemSup >= 4) {
fld.strokeColor = color.transparent;
fld.fillColor = color.transparent;}
else if(nRemSup = "") {
fld.strokeColor = color.transparent;
fld.fillColor = color.transparent;}
Thank you, stay safe
