Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#10361 closed defect (duplicate)

dijit.form.NumberTextBox - commas not working in non-english locales

Reported by: Al Briggs Owned by: Douglas Hays
Priority: high Milestone: 1.4
Component: Dijit - Form Version: 1.3.2
Keywords: Cc: Adam Peller
Blocked By: Blocking:


Using the NumberTextBox? and the formattting works great with European formatting for numbers - swapping commas for fullstops (periods) and the other way around.

However input is not so good if I input 1.000 - this is correctly interpreted as 1000 but 1,2 is not interpreted as 1.2. Instead when 1,2 is entered the validation box goes yellow and the invalid icon is displayed.

Specifically I am working in the German locale (de).

Attachments (1)

index.html (1.5 KB) - added by Al Briggs 12 years ago.
'de-de' exmaple of non working input

Download all attachments as: .zip

Change History (10)

comment:1 Changed 12 years ago by bill

I'm looking at in the second euro example, which is hardcoded to de locale. "1,2" doesn't work because you need two digits after the comma, but "1,20" is working fine.

Is that page working for you? Can you attach a test file where it's failing?

comment:2 Changed 12 years ago by bill

(In [20845]) Fix some invalid tooltips (users don't have to type the dollar sign or commas when entering currency), and javascript lint errors. Refs #10361.

comment:3 Changed 12 years ago by Douglas Hays

This worked for me:

<input dojoType="dijit.form.NumberTextBox" value="1.2" lang="de-de" constraints="{pattern:'#.############',fractional:[true,false]}">

comment:4 Changed 12 years ago by Adam Peller

Resolution: invalid
Status: newclosed

Please reopen if you have a failing test case.

comment:5 Changed 12 years ago by Al Briggs

Resolution: invalid
Status: closedreopened

I didn't explain the problem well enough - so please find an attached example html page.

The problem comes when you have a formatted number for example if I want a number formatted with 6 decimal places.

In the attached html you will see the value is initialized with 1.2 and formatted for display as 1,200000 - but if you input 1,2 then the box shows the input is invalid. If you enter 1.2 into the box acts normally. This means that the box works differently depending on whether you are using decimal or comma. In the case when input is in 'de-de' it should really complain when the user input 1.2 as this is not valid and 1.200 would be a valid input.

Changed 12 years ago by Al Briggs

Attachment: index.html added

'de-de' exmaple of non working input

comment:6 Changed 12 years ago by bill

Cc: Adam Peller added
Owner: set to Douglas Hays
Status: reopenednew

Assigning to Doug although this may be a problem with the the dojo.number code, in which case it should go to Adam... (or maybe it's a user error but the test case seems OK to me).

Note that the error is still hapenning in 1.4 trunk.

comment:7 Changed 12 years ago by Douglas Hays

Milestone: tbd1.4
Resolution: duplicate
Status: newclosed

2 issues that the user is complaining about: 1) 1.2 and 1,2 are acting differently in v1.3, and 2) 1,2 should be valid.
The first problem is already fixed in v1.4. The second problem is a user-error. The testcase specifies places:6 but then 1,2 is invalid since you only specified 1 decimal place. In v1.3, an input of 1.2 bypassed this check and was reformatted but should have also been invalid for the same reason. Since you want to specify a variable number of places, use places:'0,6' instead. This allows you to specify between 0 and 6 decimal places, but the number will be formatted to 6 places.

comment:8 Changed 12 years ago by Al Briggs

marvellous thanks for you help! All problems gone with correct format - even in 1.3.2

comment:9 Changed 11 years ago by bill

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