These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Min/max range of values

PetafromOz
Registered: Jun 8 2009
Posts: 230
Answered

I'm going crazy. This should be the simplest thing, but for some reason I can't make it work.

I have 3 columns in a table - Min/Max/Actual Hazard Value.

The Min & Max columns are made up of 'Read Only' Numeric Fields and each contain a minimum & maximum value respectively.
The Actual Hazard Value column is a 'User Entered-Optional' Numeric Field.

I want to restrict the user to being able only to enter an 'Actual Hazard Value' that falls within the corresponding Min/Max ranges.
I've tried many things, but have ended up with the following in an Exit event in the 'Actual Hazard Value' field:

form1.firstPage.HazTbl.Haz[1].Hazh::exit - (JavaScript, client)
if(this.rawValue < Haz[1].HazMin.rawValue && this.rawValue > Haz[1].HazMax.rawValue)
xfa.host.messageBox("This h factor must be between 10 and 60. Please re-enter");

But it doesn't work.
It lets me enter any number I like.

Another way I did it was in the case of one field where the min & max were the same, so the user has to enter 100 or nothing at all. For that I tried this:

form1.firstPage.HazTbl.Haz[0].Hazh::exit - (JavaScript, client)
if(this.rawValue != 0 || this.rawValue != 100)
xfa.host.messageBox("This h factor can only be 0 or 100, please re-enter");

But that returned the message no matter what was entered.
I give up!

Can someone please assist?

from way... underground at Parkes - central West NSW - Australia

jonom
Registered: Jan 31 2008
Posts: 133
PetafromOz wrote:
if(this.rawValue < Haz[1].HazMin.rawValue && this.rawValue > Haz[1].HazMax.rawValue)
I think that should be an OR statement - you're saying "if less than AND if more than" - that's a tough target to hit. ;)
PetafromOz
Registered: Jun 8 2009
Posts: 230
Hi Jonom, Good point - although or (||) doesn't seem to work either. Any ideas?

from way... underground at Parkes - central West NSW - Australia

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
According to the LiveCycle Designer Scripting Refernce the Logical OR is "|" or "or" and the logical AND is "&" or "and".
if(this.rawValue < Haz[1].HazMin.rawValue | this.rawValue > Haz[1].HazMax.rawValue)xfa.host.messageBox("This h factor must be between 10 and  60.  Please re-enter");

or
if(this.rawValue < Haz[1].HazMin.rawValue or this.rawValue > Haz[1].HazMax.rawValue)xfa.host.messageBox("This h factor must be between 10 and  60.  Please re-enter");

Note that Acrobat JS has the and (&) and or (|), the bitwise AND (&&) and bitwise OR (||). It also has the logical NOT (!) operator.

George Kaiser

PetafromOz
Registered: Jun 8 2009
Posts: 230
Ah, that's it. Thanks gkaiseril.

from way... underground at Parkes - central West NSW - Australia