A while ago I needed to allow users to enter a monetary value into a text input in an iOS app. There seem to be a few approaches to doing this, such as:
- Use a text field with a full keyboard and validate what the user entered, or only accept numeric input and a period or comma character
- Use a text field with a numeric keypad, but don't allow minor units (cents/pence) as there is no period or comma character available on this keypad
- Use spinners
To me, none of these options gives a good user experience; I find the best approach is what many ATMs do, which is to allow you to enter only the digits, but have a fixed decimal separator. So, to enter '123.45' you would type 1-2-3-4-5; to enter '18.00' you would type 1-8-0-0; and so on.
In this post, I am going to do this in iOS with a text input and a numeric keypad. The Objective-C code for this is available on github.