vue rules 限制用户输入为纯数字正整数,且不为0
// 表单校验rules: {classHours:[{"pattern": /^[0-9]*$/,"message": "只能输入正整数"}],},代码<el-input v-model="form.classHours" @keyup.native="ceshi(this)" style="width:80px"/>ceshi(val){this.form.
·
// 表单校验
rules: {
classHours:[
{"pattern": /^[0-9]*$/,"message": "只能输入正整数"}
],
},
代码
<el-input v-model="form.classHours" @keyup.native="ceshi(this)" style="width:80px"/>
ceshi(val){
this.form.classHours = this.form.classHours.replace(/\D/g, '');
if(this.form.classHours ==0){
this.form.classHours = '';
}
},
更多推荐
已为社区贡献25条内容
所有评论(0)