react-native-masked-text icon indicating copy to clipboard operation
react-native-masked-text copied to clipboard

Currency not well formatted

Open mjm918 opened this issue 4 years ago • 5 comments

image image

If I type slowly, I don't have any issue.

However, if I type fast, I always get the error as shown in the picture.

I have tested in both android & iOS. I am using the following code

                        <TextInputMask
                                type={'money'}
                                options={{
                                    precision: 2,
                                    separator: '.',
                                    delimiter: ',',
                                    unit: 'RM',
                                    suffixUnit: ''
                                }}
                                value={allPrice}
                                includeRawValueInChangeText={true}
                                onChangeText={(maskedText, rawText) => {
                                    this.setState({
                                        allPrice: maskedText,
                                        allPriceRaw:rawText
                                    });
                                }}
                                style={inFileStyles.allPriceInput}
                                placeholder={ lang.price }
                            />

mjm918 avatar Sep 23 '19 06:09 mjm918

I have the exact same issue

lucasromanojf avatar Mar 04 '20 23:03 lucasromanojf

@mjm918 did you find a solution?

Same issue here. Any solution for that?

fgagneten avatar Nov 23 '20 17:11 fgagneten

I don't use their textinputmask anymore but yeah i still use their mask service and set the value in textinput. this library seems to be dead

mjm918 avatar Nov 24 '20 02:11 mjm918

@mjm918 I solved this issue using the following workaround:

onChangeText={(maskedText, rawText) => {
        // Add this line
        maskedText = parseInt(maskedText.replace(/\.|,|RM/g, ""), 10) / 100;

        this.setState({
          allPrice: maskedText,
          allPriceRaw: rawText,
        });
}}

joaooliveeira avatar Feb 17 '21 21:02 joaooliveeira