Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5355 Zobrazení

Hello,

I have a float fields like this:

abc = fields.Float()

In the UI,  I want to set the float fields so that when the user is inputting the specific number, a thousand separator (,) should be added automatically in realtime to the number once it increments by 3 figures.....thousand, million, billion, etc... and when erased to below 4 figures the number goes back to normal.

Of course, when I click the save button, it will follow the thousands separator format that I set up in Translations -> Language -> English (US)


Please help!

Thank you!

Avatar
Zrušit
Autor Nejlepší odpověď

Finally, I resolved my wish. Just create a widget with the function of auto populate commas or dots when the user enters values into the float field. The code look like this:

            var input = this.$el.html();

            var output = input.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".")

And it works fine after click a button!

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
4
zář 18
5422
1
srp 20
4774
2
čvc 19
4286
1
lis 22
4335
2
srp 25
3632