Is it possible to have a TextInput for react native that allows only lowercase input?
As of now, tried this code:
state = { login: '' }
changeUsernameToLowercase = (input) => {
var temp = input.toLowerCase()
this.setState({login: temp})
}
<TextInput
onChangeText={(login) => this.changeUsernameToLowercase(login)}
value={this.state.login}
autoCapitalize='none' />
But it seems to not work on some android devices.
Maybe there is a more efficient way on doing this?
This might solve your problem, it works for me.
Add these three lines inside TextInput
, original answer source
autoCapitalize="none"
secureTextEntry={true}
keyboardType={"visible-password"}
example
import React, { useState } from "react";
import { View, TextInput } from "react-native";
export default function App () {
const [text,setText] = useState('');
return (
<View>
<TextInput
autoCapitalize="none"
secureTextEntry={true}
keyboardType={"visible-password"}
style={{height: 40, borderColor: 'gray', borderWidth: 1,width:"100%"}}
value={text}
onChangeText={ text => setText(text.toLowerCase()) }
/>
</View>
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With