Numeric field input internationalization
Numeric field input internationalization
I'm using DataTables and Editor in solutions which use different languages. I use the internationalization options in DataTable or the render function to format the outputs (decimal numbers, currency, dates) according to the culture selected by the user, but I didn't find a way to tell Editor to use a comma as decimal separator for numeric fields (I'm using inline input, but I don't think this is relevant).
This discussion has been closed.
Answers
Hi,
Are you using a
text
input element for the numeric input? The issue there is that the input is freeform text, so really you would need to do any deformatting on the server-side (if you are using the PHP libraries you could consider usingsetFormatter
for example).The other option might be to extend the
text
input type to make it a numeric input, in which case the input options would be governed by the browser's internationalisation rules and the locale settings of the host computer:number
has reasonably good cross browser support, but not on old browsers.Allan
edit I called it
numeric
before - the input type isnumber
.Yes, it's number and it works with Chrome and Firefox. Unfortunately it doesn't work with IE (not even IE 11) which has a few known issues with the type 'number' and I need to support IE.
I would be happy to process the input on the server (or on the client), but I couldn't find a way to do it.
As far as I understand, Editor takes the numeric value from row/cell Data and convert it to a string using the US format (decimal point) and I could find a way to change that. After editing the input validation (which give a NaN result if I try to use a comma to separate decimals) happens before any of the Editor event (even preSubmit) and I couldn't find a way to replace ',' with '.'
Have you read through the formatter documentation? Specifically
setFormatter
could be used to deformat from a localised number to what the database is expecting.Allan