Expand my Community achievements bar.

Positive Value only Display or Edit Pattern

Avatar

Level 2
Hello, could someone please explain how I can prevent a negative result in a calculation field? i.e., a result less than zero. In other words, how can I ensure that users only enter positive values in a numeric field, and that the subsequent simple "subtract" calculation will also remain positive?



Harry
3 Replies

Avatar

Former Community Member
Dear Harry



You can prevent a negative result by placing on validate event the following javascript code:

if (this.rawValue <0) {

this.rawValue =""

}

Avatar

Level 2
THANKS NASSIA, this works for disallowing negatives by force, however it gives me script failed alert.



Would you know how to suppress "Script Failed" alerts, such as this:



Script failed (language is formcalc; context is

xfa[0].form[0].form1[0].SF_CalculationTable[0].acview[1])

script=(ac[1] / tr[1]) * 100

Error: arithmetic over/underflow.

.

.

. (+ 25 more...)



These seem to be only happening because the field is not yet populated, (except with zeros). How do I suppress this error, because the form works fine.

Avatar

Former Community Member
The script failed because the language is formcalc. You must select javascript language from the script editor.



see: http://partners.adobe.com/public/developer/en/livecycle/lc_designer_validation_tutorial.pdf

(figure:4 page:3)