[Custom Input Masks] Percentage with 3 decimals is set to 100%
Question
Forge component by Sara Gonçalves

Hi,

When I use the percentage mask with 3 digits (12,345 comma as decimal separator), after pressing the submit button, the value changes to 100%. When I use 4 or more digets (12,3456), it doesn't chage. How can I solve this problem?

BTW, useing more than 2 digets was only posible after adding "digits: decimalDigits" to the javascriptscript of "MaskPercentage".

Raymond

Hello Raymond, 

i'm facing the same issue here. Did you solve it?


Cheers,

Guilherme

Hi Guilherme,

Sorry, no solution yet. It was for a small application (5 users) and small budget. Therefore I was asked to let it rest and work on other issues.

Raymond

mvp_badge
MVP

Hi Guilherme,

I can add a version where is possible to have more than 2 decimal digits on percentage mask but you will have to use "." as the decimal separator. As Raymond said when you use comma the component has a problem that I still couldn't find the solution.

Is that enough for you? 

Regards,

Marcelo

Hi Marcelo and Raymond, 

i developed this workaround that is working so far. In javascript of MaskPercentage webblock added these lines.

if($(elementID).val() < 100)
        $(elementID).val(parseFloat(Math.round($(elementID).val() * 100) / 100).toFixed(decimalDigits));


In attach you can find the complete javascript extracted from Custom Masks last version with these lines already.

Hope it helps.


Cheers,

Guilherme

MaskPercentage.txt

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.