Input input box sets numerical limit

Preface

  • Some requirements require limiting the input content, such as amount, and the input content must be of numeric type.

Method to realize

  • Because the amount has a decimal point, you need to be able to enter the decimal point in addition to the numbers.
<el-input
  v-model="number"
  onkeyup="value=value.replace(/[^\d.]/g,'')"
/>
  • If you only need to enter numbers
<el-input v-model="number" onkeyup="value=value.replace(/[^\d]/g,'')" />

Guess you like

Origin blog.csdn.net/yuan0209/article/details/129970965