How to allow only numbers in textbox in reactjs?

后端 未结 7 514
感情败类
感情败类 2020-12-03 05:03

How to allow only numbers in textbox in reactjs using regular expression only?

相关标签:
7条回答
  • 2020-12-03 05:52
    countDecimals(value) {
      return value % 1 ? value.toString().split(".")[1].length : 0;
    };
    
    handleOnChangeAmount(id, e) {
      let count = this.countDecimals(e.target.value);
      if (count === 3) {
        e.preventDefault();
      }
    }
    
    0 讨论(0)
提交回复
热议问题