Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Yes, that's what I meant, sorry - it's in the calculation action. Does it look OK to you if that is the case?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now