长度为10位,最多带两位小数的正则
{
pattern: /^(-)?[0-9]((\d)+)?(\.(\d)+)?$/,
message: "请输入数字",
trigger: "blur"
},
{
pattern: /^[0-9]((\d)+)?(\.(\d)+)?$/,
message: "请输入非负数",
trigger: "blur"
},
{
pattern: /^[0-9](\d){0,9}?(\.(\d+)?)?$/,
message: "整数部分长度不能超过10位",
trigger: "blur"
},
{
pattern: /^[0-9](\d){0,9}?(\.(\d+))?$/,
message: "请输入正确的数字格式",
trigger: "blur"
},
{
pattern: /^[0-9](\d){0,9}?(\.(\d){1,2})?$/,
message: "请最多保留两位小数点",
trigger: "blur"
}
长度10位的整数
{
pattern: /^[1-9](\d+)?$|^0$/,
message: "请输入整数",
trigger: "blur"
},
{
pattern: /^[1-9](\d){0,9}?$|^0$/,
message: "长度不能超过10位",
trigger: "blur"
}
或
{
pattern: /^[1-9][0-9]*$|^0$/,
message: "请输入格式正确的整数"
},
{
pattern: /^[1-9][0-9]{0,9}?$|^0$/,
message: "长度不能超过10位",
trigger: "blur"
}
百分比的整数
{
pattern: /^[1-9][0-9]*$|^0$/,
message: "请输入格式正确的整数"
},
{
pattern: /^[1-9][0-9]{0,8}?$|^0$/,
message: "长度不能超过9位",
trigger: "blur"
},
{
pattern: /^100$|^[1-9]\d$|^\d$/,
message: "请输入0至100的整数",
trigger: "blur"
}
后续待补充
网友评论