Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
5351 มุมมอง

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!

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

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!

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
Custom float field auto rounding? แก้ไขแล้ว
4
ก.ย. 18
5418
1
ส.ค. 20
4770
2
ก.ค. 19
4286
1
พ.ย. 22
4329
2
ส.ค. 25
3627