Opened 10 years ago

Closed 10 years ago

Last modified 8 years ago

#9438 closed defect (fixed)

CurrencyTextBox: shows errors when inputting negative values

Reported by: Phil DeJarnett Owned by: Douglas Hays
Priority: high Milestone: 1.4
Component: Dijit - Form Version: 1.3.0
Keywords: CurrencyTextBox formatter negative Cc: Adam Peller
Blocked By: Blocking:

Description (last modified by bill)

I thought I had seen this before, but I cannot find a bug report for it.

Using the default USD formatter, the CurrencyTextBox shows an error when editing or viewing a negative value. For example, if you look at the sample at http://docs.dojocampus.org/dijit/form/CurrencyTextBox

You can change the value, manually, to -54775.86. This shows an error while inputting it, but "corrects" itself to (54775.86). When you click to edit it again, it shows an error, but still shows the value to edit as -54775.86.

Now, if you then change the value to -54775.00 (note the zeros), the field will no longer validate. However, 54775.00 does validate, as does (54775.00). This actually prevents the form from submitting. If you click in the negative field, even if it was validated, the field becomes invalid.

This is an even bigger issue when programmatically updating a field. In my case, I have revenue, cost, and profit fields. If the profit field gets updated by code to, for example, ($10.00), when the user tabs through it, they see an error, and the form won't submit.

The problem is two-fold:

Problem 1: Despite what everyone thinks, I think only accountants use the ($1.00) format. Normal people I think would find it easier to read -$1.00. While I can manually overwrite the pattern constraint, this disables the TextBox? from switching between formatted and unformatted input. This causes other problems, such as changing $11,000.00 to $1,100: the user now has to manually update the location of the thousands separator.

Solution 1: There should be a way to select the -$1.00 format for USD.

Problem 2: Even in the default implementation, the currency field show errors that it should not show while editing negative values. I can easily ignore problem 1 if problem 2 was solved.

Solution 2: The default CurrencyTextBox should not show an error when editing negative values.

I believe this is a pretty major bug, because CurrencyTextBox is almost useless if you need to allow negative values.

Change History (4)

comment:1 Changed 10 years ago by bill

Description: modified (diff)
Owner: set to Douglas Hays
Summary: dijit.form.CurrencyTextBox shows errors when inputting negative valuesCurrencyTextBox: shows errors when inputting negative values

Hmm I thought that ($123) was just a display format, like $123, and that the input/edit format was always pure numeric, like -123 or 123. In other words, I thought that both the dollar sign and parentheses were only displayed when the field was not in edit mode.

comment:2 Changed 10 years ago by Adam Peller

Cc: Adam Peller added

comment:3 Changed 10 years ago by Douglas Hays

Milestone: tbd1.4
Resolution: fixed
Status: newclosed

(In [19920]) Fixes #9438. Set the constraints type='decimal' during editing to bypass currency patterns. The problem about how to show -$1.23 instead of ($1.23) is a separate issue with cldr data and will need to be addressed in a separate enhancement ticket. As a viable workaround, you can set the lang of your currency widget to en-gb and it'll display as -$1.23

<script type="text/javascript" src="../../../dojo/dojo.js"
        djConfig="isDebug: true, parseOnLoad: true, extraLocale: ['en-gb']"></script>
blah
blah
<input value="54775.01" dojoType="dijit.form.CurrencyTextBox"
        constraints="{fractional:true}"
        lang='en-gb'
        currency="USD"/>USD

comment:4 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.