input输入框输入纯数字、数字及小数点

1.纯数字
<div>
  <el-form-item label="开户行:" prop="bankName" >
    <el-input v-model="formData.bankName" maxlength="100"  @keyup.native="proving"/>
  </el-form-item>
</div>

methods方法

proving() {
  this.formData.bankName = this.formData.bankName.replace(/[^\.\d]/g,'');
  this.formData.bankName = this.formData.bankName.replace('.','');
},

 



2.数字及两位小数点
<el-input 
v-model="form.personIncome"
onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')"
placeholder="单位:元">
</el-input>
posted @ 2020-09-01 14:11  小白&小菜  阅读(2039)  评论(0编辑  收藏  举报
我是一个小菜鸟,飞呀飞呀,快飞高