是否合法IP地址
const checkIPCode = (rule, value, callback) => {
if (/^(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])$/
.test(value) == false) {
callback(new Error("请输入正确的ip地址"));
} else {
callback();
}
}
是否合法端口
const checkPortCode = (rule, value, callback) => {
if (/^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{4}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/.test(value) == false) {
callback(new Error("请输入正确的端口号"));
} else {
callback();
}
}
标签:25,Vue,false,form,rules,value,callback,test,const
From: https://www.cnblogs.com/leepandar/p/18161752