102
Views
6
Comments
[Input Masks Library] Incorrect value when decimal has no decimal part
Question
Forge component by Labs
12
Published on 02 Oct 2019

Hello.

When using the currency mask on an edit screen, if the value got from the fetched data is for instance 123.45, it binds the value correctly:

If the value is for instance 1500.00, the mask doesn't work correctly  and shows to the user the value 15.00:

Can you guys give us help on fixing this (multiplying by 100 is not an option)?

Thank you!


Cheers,

Gonçalo M.

Rank: #2766

Hi Gonçalo,

I've been testing this component and checking what you are explaining and here's my thoughts.

Following your 1000.50 example, the problem is that the value is stored in the database as 1000.5, no matter if its data type is Currency or Decimal. So when the Currency mask gets the value, it assumes that the 2 last digits are the decimal part, which becomes 100.05.

You can overcome this issue in 2 different ways: 

  • If you store the value as Text, you won't have this issue, since it will be stored as "1000.50". You just have to convert it to decimal whenever you need to use it as a decimal.
  • After fetching the (Currency or Decimal) data from the database, which returns 1000.5, use the FormatDecimal() built-in function. Example: FormatDecimal(your_currency_value, 2, ".", "") will return you a text with the value "1000.50".

Let me know if this helps.


Best regards,

André

Staff
Rank: #67

Also, another scenario that doesn't work is for instance 1000.50 since appears 1000.50:


Cheers,

GM

Rank: #2411

Hello,


I am also stuck with this issue. And as stated by Gonçalo, this is a very common use case, the component should not generate such a basic issue. It would be nice to have some update soon or at least a better workaround.


Thank you,

Tomás Silva

Rank: #68498

Still happened on me develop using this plugin 

This thread from 2018, now 2020, and still happened

Rank: #17068

Yup, I have a value of 1,50, shows up as 0,15 in my input field. Please fix this, we are not going to store numbers as text in the database because of this bug...