I am working on a React Native app. I am using Formik for my forms. And now my requirement is I have a TextInput where the user will type a price. This input field should add comma separators for 1000s for example if I type 10000 the input field should show as 10,000 and if I type 100000 it should show as 100,000. How to do that. FYI my TextInput is imported from React Native Paper
Below is my code:
<TextInput
style={{ width: "auto", marginBottom: 10 }}
mode="outlined"
label="Starting Price"
placeholder="25,000"
inputMode="numeric"
defaultValue="0"
left={<TextInput.Affix text="LKR" />}
onChangeText={obj.handleChange("startingPrice")}
value={obj.values.startingPrice}
/>
You have an handleChange function. You can use this code in your function.
This is an example
Output is: 100,000
I hope it helps.