CaioQuirinoMedeiros / react-native-mask-input

🎭:iphone: A simple and effective Text Input with mask for ReactNative on iOS and Android. Includes obfuscation characters feature.
https://www.npmjs.com/package/react-native-mask-input
MIT License
309 stars 31 forks source link

How to remove leading zeroes #27

Closed KrisLau closed 2 years ago

KrisLau commented 2 years ago

Exactly as the title: How do I remove the leading zeroes from a currency input using a createNumberMask as its mask?

CaioQuirinoMedeiros commented 2 years ago

@KrisLau if you want a currency input I recommend this one: https://github.com/CaioQuirinoMedeiros/react-native-currency-input

KrisLau commented 2 years ago

@CaioQuirinoMedeiros Does that remove leading zeroes?

KrisLau commented 2 years ago

also would I be able to get help on another one of my masks? I'm trying to mask a number (in ms) to seconds

CaioQuirinoMedeiros commented 2 years ago

@KrisLau I don't get what you want... the documentation of both libraries are pretty clear, you should only come here if you face a problem

KrisLau commented 2 years ago

Sorry I'll explain in more detail! So the issue I was having in the original post has been resolved by moving to the https://github.com/CaioQuirinoMedeiros/react-native-currency-input package so i'll close the issue. Thank you for that!

The second issue I'm having is I have an input where users enter the number of milliseconds and I wanted the milliseconds to be formatted to seconds and milliseconds. like this ss:mm. I thought using [/\/d/, /\/d/, ':', /\/d/, /\/d/] would work but it was not even updating the value correctly

CaioQuirinoMedeiros commented 2 years ago

try [/\d/, /\d/, ':', /\d/, /\d/]

KrisLau commented 2 years ago

try [/\d/, /\d/, ':', /\d/, /\d/]

@CaioQuirinoMedeiros Isn't that the same regex expression as what I had already tried (in my previous comment) unless I'm missing something? I thought that would work as well but it was not working for me. Not sure if this is important but the number could also be more than 4 digits

EDIT: I figured out how to get it to work -

createNumberMask({
    delimiter: '',
    seperator: '.',
    precision: 3
})`

Thank you for all the help!