# Best Practice for Currency Input in a TextField?

**URL:** <https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192>\
**Category:** Code Sharing\
**Created:** [April 30, 2025, 8:02pm UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192 "2025-04-30T20:02:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![FABRICE\_GARCIA](https://forum.xojo.com/user_avatar/forum.xojo.com/fabrice_garcia/32/6636_2.png) [@FABRICE\_GARCIA](https://forum.xojo.com/u/FABRICE_GARCIA)\
**Post date:** [April 30, 2025, 8:02pm UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192/1 "2025-04-30T20:02:23Z")

</div>

Hi everyone,

I’m exploring the most reliable way to handle currency input in a `TextField`.

I’ve built a custom solution that filters keystrokes and formats the number as you type. However, I’m not convinced by using `Format` or `Validation Mask` — they feel too rigid and inflexible for this use case.

What do you think is the best approach?  
Let’s discuss and maybe find a better way together.

My project link on GitHub : [Xojo-Currency-Input](https://github.com/Fab2bprog/Xojo-Currency-Input)

Thanks! 😁

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [April 30, 2025, 8:18pm UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192/2 "2025-04-30T20:18:51Z")

</div>

Use GraffitSuite currency field. You can thank me later.  
GraffitiSuite is a plugin but worth the $$.

---

<div class="post-metadata">

**Author:** ![FABRICE\_GARCIA](https://forum.xojo.com/user_avatar/forum.xojo.com/fabrice_garcia/32/6636_2.png) [@FABRICE\_GARCIA](https://forum.xojo.com/u/FABRICE_GARCIA)\
**Post date:** [April 30, 2025, 8:21pm UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192/3 "2025-04-30T20:21:16Z")

</div>

The goal is not to pay. From this perspective you can pay for everything, and even someone to do the program. The goal here is to offer an open source solution that everyone can apply and benefit from.

---

<div class="post-metadata">

**Author:** ![Gary\_Smith](https://forum.xojo.com/user_avatar/forum.xojo.com/gary_smith/32/473_2.png) [@Gary\_Smith](https://forum.xojo.com/u/Gary_Smith)\
**Post date:** [April 30, 2025, 8:27pm UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192/4 "2025-04-30T20:27:43Z")

</div>

I understand.  
I tried all kinds of ways to do it with a textfield but spent way too much time on it. My time is money so I went with GraffitiSuite.  
Maybe someone else has a solution.  
Thanks

---

<div class="post-metadata">

**Author:** ![FABRICE\_GARCIA](https://forum.xojo.com/user_avatar/forum.xojo.com/fabrice_garcia/32/6636_2.png) [@FABRICE\_GARCIA](https://forum.xojo.com/u/FABRICE_GARCIA)\
**Post date:** [April 30, 2025, 8:29pm UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192/5 "2025-04-30T20:29:17Z")

</div>

Ok, but have you downloaded my code and what do you think of it ? We must not despair though! The goal is to improve the code. Let’s stay optimistic! Let’s find an open source solution together 😄

---

<div class="post-metadata">

**Author:** ![MarkusR](https://forum.xojo.com/user_avatar/forum.xojo.com/markusr/32/685_2.png) [@MarkusR](https://forum.xojo.com/u/MarkusR)\
**Post date:** [April 30, 2025, 9:49pm UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192/6 "2025-04-30T21:49:27Z")

</div>

xojo can handle currency input via fromstring tostring but it need a try catch around.  
[https://documentation.xojo.com/api/data\_types/currency.html#methods](https://documentation.xojo.com/api/data_types/currency.html#methods)

---

<div class="post-metadata">

**Author:** ![Thomas\_Roemert](https://forum.xojo.com/user_avatar/forum.xojo.com/thomas_roemert/32/827_2.png) [@Thomas\_Roemert](https://forum.xojo.com/u/Thomas_Roemert)\
**Post date:** [May 1, 2025, 10:47am UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192/7 "2025-05-01T10:47:19Z")

</div>

> [@FABRICE\_GARCIA](#):
>
> The goal is to improve the code

The following point may still be revised: Saving the decimal separator in a constant makes the whole very inflexible when it comes to different language regions. The comma as a decimal separator is more common in Europe, the point is more used elsewhere…

---

<div class="post-metadata">

**Author:** ![Jean-Yves\_Pochez](https://forum.xojo.com/user_avatar/forum.xojo.com/jean-yves_pochez/32/21769_2.png) [@Jean-Yves\_Pochez](https://forum.xojo.com/u/Jean-Yves_Pochez)\
**Post date:** [May 1, 2025, 4:25pm UTC](https://forum.xojo.com/t/best-practice-for-currency-input-in-a-textfield/85192/8 "2025-05-01T16:25:29Z")

</div>

you can get the decimal and grouping separator from the locale class
