0

i want to check and restrict the number has decimal places.i won't allow like 90.90. for that i need a key code i have tried event.nativeEvent.Key but it producing undefined.

saiRam89
  • 365
  • 1
  • 8
  • 21
  • 1
    Change your approach. You can detect the new character and remove it. onChangeText will invoke a function, thats where you can perform something like this `(text) => text === '.' ? '' : text`. Just remember to notify your user (UX). For iOS, https://facebook.github.io/react-native/docs/textinput.html#onkeypress – eden Jul 27 '17 at 08:21
  • You would need to filter the string with non allowed characters and set the state afterwards. For example: https://stackoverflow.com/a/40803430/6109263 Or use: https://github.com/benhurott/react-native-masked-text – Tobias Lins Jul 27 '17 at 11:18

0 Answers0