增加ipv6校验
This commit is contained in:
@@ -171,19 +171,6 @@ $(function(){
|
||||
},
|
||||
errorContainer: "#messageBox",
|
||||
});
|
||||
|
||||
$.validator.addMethod(
|
||||
"checkIp",
|
||||
function(value, element, params) {
|
||||
var checkIp;
|
||||
if ($("[name=ipType]").val() == 4) {
|
||||
checkIp = /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/;
|
||||
} else {
|
||||
checkIp = /\S+/;
|
||||
}
|
||||
return this.optional(element) || (checkIp.test(value) && (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256));
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -40,19 +40,6 @@ $(function(){
|
||||
errorContainer: "#messageBox"
|
||||
});
|
||||
|
||||
$.validator.addMethod(
|
||||
"checkIp",
|
||||
function(value, element, params) {
|
||||
var checkIp;
|
||||
if ($("[name$=ipType]").val() == 4) {
|
||||
checkIp = /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/;
|
||||
} else {
|
||||
checkIp = /\S+/;
|
||||
}
|
||||
return this.optional(element) || (checkIp.test(value) && (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256));
|
||||
}
|
||||
);
|
||||
|
||||
$("#ipSelect").change(function(){
|
||||
if($(this).prop("checked")){
|
||||
$("[name^='ipCfg']").removeProp("disabled");
|
||||
@@ -116,8 +103,6 @@ $(function(){
|
||||
|
||||
});
|
||||
$(".ipType").on("change",function(){
|
||||
var mainTableType="${mainTableType}";
|
||||
var otherTables='${_cfg.otherTables}';
|
||||
var tableName=$(this).attr("name").replace(".ipType","");
|
||||
var type=$(this).val();
|
||||
if(4==type){
|
||||
|
||||
@@ -28,6 +28,19 @@ jQuery.validator.addMethod("ip", function(value, element) {
|
||||
return this.optional(element) || (/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.test(value) && (RegExp.$1 <256 && RegExp.$2<256 && RegExp.$3<256 && RegExp.$4<256));
|
||||
}, "请输入合法的IP地址");
|
||||
|
||||
jQuery.validator.addMethod(
|
||||
"checkIp",
|
||||
function(value, element, params) {
|
||||
var checkIp;
|
||||
if ($("[name$=ipType]").val() == 6) {
|
||||
return this.optional(element) || (checkIp.test(value) && (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256));
|
||||
} else {
|
||||
checkIp = /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/;
|
||||
return this.optional(element) || /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i.test(value);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
jQuery.validator.addMethod("abc",function(value, element) {
|
||||
return this.optional(element) || /^[a-zA-Z0-9_]*$/.test(value);
|
||||
},"请输入字母数字或下划线");
|
||||
|
||||
Reference in New Issue
Block a user