E
E
Eugene2015-11-15 10:59:32
JavaScript
Eugene, 2015-11-15 10:59:32

How to do correct number formatting in dijit/form/NumberTextBox?

Hello.
Essence of a question:
I use Dojo for a client part of application. Server side in Java (Spring MVC). I draw a form, a NumberTextBox is dynamically drawn on the form to display a number with the Double type. The number comes from the server as 55.01, for example. As a pattern for the widget, #,## is set (namely, a comma as a separator of the integer and fractional parts, because the locale is ru). Since the number comes as a number, it comes with a dot as a separator, and the widget draws only the integer part for me, and rounds it up, since after casting to a string I don’t get into the pattern.
If you set a pattern like #.##, then at the first rendering everything is drawn, but if you change the value, then client validation does not pass, because in the Russian locale, the separator is still a comma (if you change the locale to En in the browser, everything works fine).
The real question is how to make this thing work correctly, regardless of the locale? I tried to set different patterns, it did not help. Passing a number as a string to the client is also not suitable.
If anyone has encountered such a problem (maybe not necessarily in dojo, in other JS frameworks), tell me how did you solve it?
Thank you for your attention.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question