Here is my code there are 3 input fields, in uniqueIdNo whenever I have to type it should automatic convert to uppercase. I am using the toUpperCase() function, it converts to the upper case also, but if I am writing ab two-letter its coming AAB means whatever the first letter I am typing it adding that and coming two times.
this.state={
firstName: props.firstName || '',
lastName: props.lastName || '',
uniqueIdNo:props.uniqueIdNo || '',
}
onChangeText = async (text, identifier) => {
if (identifier === "FN") {
this.setState({
firstName: text
});
} else if (identifier === "LN") {
this.setState({
lastName: text
});
} else if (identifier === "UIN") {
this.setState({
uniqueIdNo: text.toUpperCase()
});
}
};
<Item style={{ borderColor: "#00fff", borderBottomWidth: 0.6 }}>
<Input
value={firstName}
keyboardType="default"
onChangeText={text => this.onChangeText(text, "FN")}
/>
</Item>
<Item style={{ borderColor: "#00fff", borderBottomWidth: 0.6 }}>
<Input
value={lastName}
keyboardType="default"
onChangeText={text => this.onChangeText(text, "LN")}
/>
</Item>
<Item style={{ borderColor: "#00fff", borderBottomWidth: 0.6 }}>
<Input
value={uniqueIdNo}
onChangeText={text => this.onChangeText(text, "UIN")}
/>
</Item>