Dojo – CurrencyTextBox with constraints, syntax

Dojo – CurrencyTextBox with constraints, syntax

(Disclaimer: not a developer – I am a sysadmin that's been assigned a minor set of development tasks outside my area of expertise)

I have a webapp with a form using the Dojo toolkit. Currently the form is working, but management wants a bit of logic added to the TotalValue input to flag error if the TotalValue != the sum of a couple of other fields. I am trying to get a handle on the syntax required for this.

 new CurrencyTextBox({ currency: 'USD', value: populate['items'][0].TotalValue, invalidMessage: 'Invalid amount', name: "TotalValue" }, "TotalValue"); new CurrencyTextBox({ currency: 'USD', value: populate['items'][0].HwValue, invalidMessage: 'Invalid amount', name: "HwValue" }, "HwValue"); new CurrencyTextBox({ currency: 'USD', value: populate['items'][0].SwValue, invalidMessage: 'Invalid amount', name: "SwValue" }, "SwValue"); 

I can add a line to the TotalValue

constraints: { min: 10, max: 100 } 

and the field flags properly if it is a value outside 10-100.

What I don't know how to do is how to call the current value of HwValue+SwValue in the constraints value.

I have tried:

 constraints: { min: populate['items'][0].HwValue } constraints: { min: populate['items'][0].HwValue.getValue() } constraints: { min: populate['items'][0].HwValue.get("value") } constraints: { min: this.item.HwValue } constraints: { min: this.item.HwValue.getValue() } 

Plus various permutations involving what looks like appropriate semicolons. I know that the popular['items'] options will only compare the value from the database, not the live amounts currently in the unsubmitted form, just trying to wrap my head around the syntax and get an example working.

But, the value of the HwValue field doesn't appear to be being passed to the constraints.

I assume that this is a simple issue of not knowing even the most basic syntax… Can anyone point me in the right direction?

Submitted July 12, 2017 at 08:53PM by gort32
via reddit


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s