Skip to main content
Known Participant
August 31, 2023
Question

Javascript with "OR" statement - PDF Form

  • August 31, 2023
  • 1 reply
  • 623 views

I need some help as I am new at this:  I am setting up a fillable form but I have been asked to create the text boxes change colors if the numbers entered are incorrect.  I have the code, but it is for only set of numbers for each color, Red, Yellow and Green.  I need to add a second set of numbers for Yellow and Red and I am having issues, please help if you can.  Here is the code I have so far:

var v = Number(event.value);if (v>=720 && v<=880) {event.target.fillColor = color.green;}else if (v>881 && v<=920){event.target.fillColor = color.yellow;}else if (v>920 && v<=2000) {event.target.fillColor = color.red;}else event.target.fillColor = color.white;

 

Thanks

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
August 31, 2023

The JS operator for logical OR is "||". So, for example, you can use something like this:

 

if ((v > 920 && v <= 2000) || (v>5000 && v<=10000)) {

event.target.fillColor = color.red;

}