优化业务字典、系统字典、特定服务、协议ip校验处理方式,融合代码
This commit is contained in:
@@ -150,3 +150,47 @@ jQuery.validator.addMethod("regexPassword", function(value, element) {
|
||||
return this.optional(element) || /^(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/.test(value);
|
||||
}, "一个大写,一个小写,一个符号");
|
||||
|
||||
//输入内容不得为空格
|
||||
jQuery.validator.addMethod("noBlankSpace", function(value, element) {
|
||||
return $.trim(value) != "";
|
||||
}, "不能填写空格");
|
||||
|
||||
//掩码校验,超过两位不得以0开头
|
||||
jQuery.validator.addMethod("notStartZero",function(value, element) {
|
||||
if(value.length>1&&value.length<6){
|
||||
var str = value.substr(0,1);
|
||||
if(str == '0'){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}, "请填写正确的数值");
|
||||
|
||||
//ip地址校验
|
||||
jQuery.validator.addMethod("ipCheck",function(value, element) {
|
||||
if(value.length==0||value.trim().length==0){return true;}
|
||||
var typeInt=$("select[name$='ipType']").val();
|
||||
if(typeInt==4){
|
||||
return this.optional(element)||(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.test(value) && (RegExp.$1 <256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256));
|
||||
}else if(typeInt==6){
|
||||
return this.optional(element)||/^\s*((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?\s*$/.test(value);
|
||||
}}, "请填写正确的IP地址");
|
||||
//ip地址掩码校验
|
||||
jQuery.validator.addMethod("ipMask",function(value, element) {
|
||||
if(value.length==0||value.trim().length==0){return true;}
|
||||
obj=value;
|
||||
var typeInt=$("select[name$='ipType']").val();
|
||||
if(typeInt==4){
|
||||
if(obj=="255.255.255.255"){
|
||||
return true;
|
||||
}else{
|
||||
var exp=/^(254|252|248|240|224|192|128|0)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)$/;
|
||||
var reg = obj.match(exp);
|
||||
if(reg==null){return false;}else{return true}
|
||||
}
|
||||
}else if(typeInt==6){
|
||||
if(obj=="FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"||obj==0||obj=="::"){
|
||||
return true;
|
||||
}else{return (obj > 0) && ((obj & (obj - 1)) == 0)};
|
||||
}
|
||||
}, "请填写正确的IP地址掩码");
|
||||
Reference in New Issue
Block a user