Skip to main content
Nic18
Participant
July 18, 2016
Question

Value must be between 0.5 and 200 in 0.5 increments

  • July 18, 2016
  • 2 replies
  • 558 views

I've been trying to figure out how to set a decimal field (in Adobe Experience Manager Forms Designer) so that the value must be between 0.5 and 200 in 0.5 increments.

This JavaScript in the validation field works to restrict the value between 0.5 and 200:

<= this.rawValue && this.rawValue <= 200.0;

but I haven't been able to figure out how to get the 0.5 increments part to work. I did read about the modulus/remainder function but I just can't figure out how to implement it. I'd like to have an error message appear if the value doesn't end in .0 or .5.)

I don't even know if that part of the code should be under "validate" or "calculate". I tried putting this under "calculate" based on various sample code snippets I've found online but it's not right:

nPositions = this.getField("Cell1").value;

remainder = nPositions % 0.5;

(remainder != 0) app.alert("Amount must be between 0.5 and 200 in 0.5 increments.");

Any assistance would be greatly appreciated - this is driving me crazy!

This topic has been closed for replies.

2 replies

Nic18
Nic18Author
Participant
July 18, 2016

Yes, that's what I meant, sorry - it's in the calculation action. Does it look OK to you if that is the case?

Inspiring
July 18, 2016

You must realize that the displayed value is not the same as the actual value of the field used by JavaScript. I would add the code tot he calculation action.