TextInput component should not accept other characters than numeric.
The real problem is that when you paste inside TextInput: 555 555 555, instead of 555555555, I get 555 555 5.
Other than that, I can paste whatever I want ^*D+-/6.
I tried regex on
function handler(e) {
const tmp = e.replace(/[^0-9]/g, '');
setValue(tmp)
}
Is there any good way I can catch paste event or something?
Code is simple:
export default function App() {
const [value, setValue] = React.useState('');
function handler(e) {
setValue(e);
}
return (
<View style={styles.container}>
<TextInput
value={value}
onChangeText={handler}
keyboardType="numeric"
maxLength={9}
/>
</View>
);
}