我有一个文本输入,怎么可能只允许低于 9999.99 的数字?
<TextInput
autoFocus
style={styles.inputStyle}
placeholder="0.00"
keyboardType="numeric"
maxLength={9}
autoCapitalize="none"
placeholderTextColor={Colors.white}
underlineColorAndroid={Colors.transparent}
value={billAmount}
onChangeText={this.handleTextChange}
selection={{start: cursor, end: cursor}}
/>
这是handleTextChange函数:
handleTextChange = (text) => {
const { cursor, billAmount } = this.state
let newText
newText = text.replace(/[^1-9]/g, '')
this.setState({
billAmount: newText
})
}