<el-form-item prop="get">
<el-input v-model="form.get"
@input="(val)=>{getUps(val)}"
autocomplete="off" style="width: 260px;" placeholder="请输入">
</el-input>
<span class="lengthMIn">(以英文逗号分隔)</span>
</el-form-item>
<script>
var validGet = (rule, value, callback) => {
if (value) {
var reg = /^(\d+,?)+$/;
if (!reg.test(value)) {
callback(new Error('输入不合法'));
} else {
callback()
}
} else {
callback()
}
}
export default {
methods: {
getUps(val) {
this.form.getShell = val.replace(/[^0-9,]/g, '');
},
submitForm(formName) {
this.$refs[formName].validate((valid) => {
if (valid) {
}
});
}
},
data() {
return {
rules: {
get: [{ required: true, message: '请输入' },
{ validator: validGet, trigger: 'blur' }
]
}
};
}
};
</script>
|