1

I'm trying to implement TextInput with typing digits from right to left and adding zeroes automatically while user is typing. Any ideas how to implement this correctly?

The expected behavior should look like this.

enter image description here

What I have right now:

 constructor(props) {
    super(props);
    this.state = {
      payrate: '',
    };
  }

  handleTextChange = (text) => {
    const newAmount = parseFloat(text/100);
     this.setState({
       payrate: newAmount,
     })


 <TextInput
         autoFocus
         style={[styles.textInput]}
         value={payrate}
         placeholder="0.00"
         maxLength={9}
         keyboardType="numeric"
         placeholderTextColor="#adecf5"
         onChangeText={this.handleTextChange}
         underlineColorAndroid='rgba(0,0,0,0)'
         autoCapitalize="none"
         selection={{start: cursor, end: cursor}}
         />
Lucky_girl
  • 4,543
  • 6
  • 42
  • 82
  • I have customized the TextInput for USA Number format I think yes, this can be done. Please check my blog. https://medium.com/@maulikdhameliya/how-to-format-number-input-to-usa-phone-number-format-in-react-native-e68363b0c6e4 to make it from right, give textAlign right – Maulik Dhameliya Sep 28 '18 at 11:13
  • have you solve that problem,? – jumper Jul 20 '20 at 08:22

1 Answers1

-1

We use react-native-masked-text for that, works decently. https://github.com/benhurott/react-native-masked-text/blob/master/README.md

Cole
  • 838
  • 1
  • 8
  • 25