📜  反应输入数字 - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:48.447000             🧑  作者: Mango

代码示例2
// Validation with REGEX
const rx_live = /^[+-]?\d*(?:[.,]\d*)?$/;

class TestForm extends React.Component {
  constructor() {
    super();
    this.state = {
      depositedAmount: ''
    };
  }

  handleDepositeAmountChange = (evt) => {
    if (rx_live.test(evt.target.value))
        this.setState({ depositedAmount : evt.target.value });
 }
  
  render() {
    return (
      
) } }