Problem with format number when using "input type = number"

Wappler Version : 4.1.3
Operating System : macOS Big Sur
Server Model: node v14
Database Type: Maria db 10.1
Hosting Type: custom
Project: SPA

Hi,

When I get a numeric value greater than 3 digits from the database and use this value in a number type field by adding “formatNumber (2, ‘.’, ‘,’)” the value is not displayed

in my case the field that returns the value from the database is of type DECIMAL, but the behavior is the same even using fields of type INT, BIGINT, etc

the strange thing is that if I go to the browser console the input value is correct but nothing is displayed on the screen

Actual behavior
Numeric value if greater than 3 digits not display
Numeric value if less than 4 digits work

How to reproduce

Create an API and get a numeric value of at least 4 digits
Create a page, connect the API
Create one “input type = number” and assign the value returned by the API by adding formatNumber (2, ‘.’, ‘,’)

1,000.00 is not a valid number. And a field with type of number expects a valid number:

I know this, but in my database the values are correct or at least I don’t know how to represent them differently …

the query also returns the correct value

But the formatting applied there is causing this :slight_smile:

So either remove the formatting or change the field type to text :slight_smile:

The formatter is the one set by default and it is strange that it only works well with numeric values less than 4 digits

so if I understand correctly this means that if I get a numeric value greater than 3 digits they cannot use this formatter, but I have to change the field type from number to text, right?

Pier,
Maybe you don’t really understand the issue here.
The numeric input expects a valid number value. Such as 1 or 999.00 or 1000 but not 1,000. The , used in a value there is not allowed.
The formatter you applied to your number uses a , symbol for thousands delimiter. This breaks the number which has 4 digits. And as the 3 digits number don’t use a thousands delimiter you can’t see the issue there …

As i explained above - this formatter is not the best solution for a field having type set to number. It will work fine with field type text, if you insist on formatting the number in such a way.
If you want to use a number input, don’t apply any format that will break its value being a valid number.

OK now I understand thanks @Teodor for a more detailed explanation :smile:

1 Like