In my React Native app I'm using the <Input> component from Native Base which is based on the standard <TextInput> component. I want to enforce a max length of 5 digits regardless of whether there's a decimal point. So if the user just types 1's, the max would be 11111, or 111.11. The problem is that since the input is a string, it considers the decimal point a character, so it stops me after 111.1.
How can I achieve this?
You could create a function that transforms your number into a string, remove the point and measure the length, then call this function from your onChangeText: