GeekyAnts / NativeBase

Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.
https://nativebase.io/
MIT License
20.17k stars 2.39k forks source link

How to apply mask to Input #1261

Closed Mate38 closed 6 years ago

Mate38 commented 6 years ago

Is there any way to apply mask to the of ?

akhil-ga commented 6 years ago

you can use secureTextEntry props in <Input> to mask the input

<Input secureTextEntry={true}/>
Mate38 commented 6 years ago

For password field, yes, but im talking about phone number field, documents fields.

Something like data-mask in html input

Ex: <input type="text" name="tel" data-mask="(00) 0000-0000" data-mask-selectonfocus="true" />

akhil-ga commented 6 years ago

@Mate38 NativeBase <Input> is built on top of React Native <TextInput/>. You can mask the input in any similar way we mask the text in <TextInput/>

Mate38 commented 6 years ago

It does not mask, as much as it applies the same mask that I use in other fields it does not show the mask

akhil-ga commented 6 years ago

@Mate38 can you paste a code snippet for us to test.

Mate38 commented 6 years ago

I would like to do something like this, use the floatingLabel and at the same time have a content mask on the component

<Item floatingLabel>
    <Label>Tel</Label>
        <TextInputMask
            refInput={ref => { this.input = ref }}
            mask={"+1 ([000]) [000] [00] [00]"}
        />
</Item>
lucasfls commented 6 years ago

Mate38, have you find a solution ? I'm trying to do just like you, but when i put the floating label, my text input loses the mask. I'm using react-native-masked-text

Mate38 commented 6 years ago

I built my own floating label and used the masked text behind it worked