/^(?:0|[1-9][0-9]?|100)$/
搭配element的表单验证
let patter = /^(?:0|[1-9][0-9]?|100)$/;
let isNumber = (rule, value, callback) => {
if (!patter.test(value)) {
return callback(new Error("必須飛負整數且範圍0-100"));
} else {
callback();
}
};
image.png
discount: [
{ required: true, message: "請填寫折扣", trigger: "blur" },
{ validator: isNumber }
],
image.png
网友评论