Skip to main content
Participant
March 14, 2024
Answered

Validation script for 2 text fields

  • March 14, 2024
  • 1 reply
  • 436 views

I am creating a document to where I have a minimum dimension in one column "MinRow1" and a maximum dimension in the other column "MaxRow1".  I would to see in "Textfield1" if the number entered highlights red if falls out of the either the max or min range and black text if number remains in between the high and low dimension.

This topic has been closed for replies.
Correct answer try67

You can use this code as that field's custom calculation script (and not validation, so that it also updates even when the min/max fields are edited):

 

var min = Number(this.getField("MinRow1").valueAsString);
var max = Number(this.getField("MaxRow1").valueAsString);
event.target.textColor = (event.value<min || event.value>max) ? color.red : color.black;

 

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 14, 2024

You can use this code as that field's custom calculation script (and not validation, so that it also updates even when the min/max fields are edited):

 

var min = Number(this.getField("MinRow1").valueAsString);
var max = Number(this.getField("MaxRow1").valueAsString);
event.target.textColor = (event.value<min || event.value>max) ? color.red : color.black;