加入验证规则TCP,UDP协议端口可以不为0其他协议端口必须为0端口号不为0时必须选择协议
This commit is contained in:
@@ -208,7 +208,44 @@ jQuery.validator.addMethod("httpCheck",function(value, element) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
/*协议端口校验
|
||||||
|
* 规则TCP,UDP协议端口可以不为0
|
||||||
|
* 其他协议端口必须为0
|
||||||
|
* 端口号不为0时必须选择协议
|
||||||
|
* */
|
||||||
|
jQuery.validator.addMethod("protocolPort",function(value, element) {
|
||||||
|
var tcp=6,udp=17,protocolVal,srcPortVal,destPortVal;
|
||||||
|
var name=$(element).attr('name');
|
||||||
|
if(name.indexOf("protocol")>-1){
|
||||||
|
protocolVal=value;
|
||||||
|
}
|
||||||
|
if(name.indexOf("srcPort")>-1){
|
||||||
|
srcPortVal=value;
|
||||||
|
}
|
||||||
|
if(name.indexOf("destPort")>-1){
|
||||||
|
destPortVal=value;
|
||||||
|
}
|
||||||
|
if(protocolVal){
|
||||||
|
var srcPortElement=$("[name='"+name.replace("protocol","srcPort")+"']");
|
||||||
|
srcPortVal=srcPortElement.val();
|
||||||
|
var destPortElement=$("[name='"+name.replace("protocol","destPort")+"']");
|
||||||
|
destPortVal=destPortElement.val();
|
||||||
|
}else if(srcPortVal){
|
||||||
|
var protocolElement=$("[name='"+name.replace("srcPort","protocol")+"']");
|
||||||
|
protocolVal=protocolElement.val();
|
||||||
|
}else if(destPortVal){
|
||||||
|
var protocolElement=$("[name='"+name.replace("destPort","protocol")+"']");
|
||||||
|
protocolVal=protocolElement.val();
|
||||||
|
}
|
||||||
|
if((protocolVal==0&&srcPortVal>0)||(protocolVal==0&&destPortVal>0)){
|
||||||
|
$.validator.messages.protocolPort=$.validator.messages.protocolPort;
|
||||||
|
}else if((protocolVal!=tcp&&protocolVal!=udp&&srcPortVal>0)||(protocolVal!=tcp&&protocolVal!=udp&&destPortVal>0)){
|
||||||
|
$.validator.messages.protocolPort=$.validator.messages.protocolPort1;
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
//ip地址校验
|
//ip地址校验
|
||||||
jQuery.validator.addMethod("ipCheck",function(value, element) {
|
jQuery.validator.addMethod("ipCheck",function(value, element) {
|
||||||
|
|||||||
@@ -72,6 +72,8 @@
|
|||||||
go_back:"Go Back Policies",
|
go_back:"Go Back Policies",
|
||||||
log_5_minutes:"Log For The Last Five Minutes",
|
log_5_minutes:"Log For The Last Five Minutes",
|
||||||
log_1_hour:"Log For The Last Hour",
|
log_1_hour:"Log For The Last Hour",
|
||||||
input:"Please Enter "
|
input:"Please Enter ",
|
||||||
|
protocolPort:"TCP protocol or UDP protocol must be chosen when port is greater than 0",
|
||||||
|
protocolPort1:"Only when TCP protocol or UDP protocol is chosen can port greater than 0"
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
|||||||
@@ -72,6 +72,8 @@
|
|||||||
go_back:"Go Back Policies",
|
go_back:"Go Back Policies",
|
||||||
log_5_minutes:"Log For The Last Five Minutes",
|
log_5_minutes:"Log For The Last Five Minutes",
|
||||||
log_1_hour:"Log For The Last Hour",
|
log_1_hour:"Log For The Last Hour",
|
||||||
input:"Please Enter "
|
input:"Please Enter ",
|
||||||
|
protocolPort:"TCP protocol or UDP protocol must be chosen when port is greater than 0",
|
||||||
|
protocolPort1:"Only when TCP protocol or UDP protocol is chosen can port greater than 0"
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
|||||||
@@ -72,6 +72,8 @@
|
|||||||
go_back:"返回配置界面",
|
go_back:"返回配置界面",
|
||||||
log_5_minutes:"5分钟日志量",
|
log_5_minutes:"5分钟日志量",
|
||||||
log_1_hour:"1小时日志量",
|
log_1_hour:"1小时日志量",
|
||||||
input:"请输入 "
|
input:"请输入 ",
|
||||||
|
protocolPort:"端口大于0时必须选择TCP协议或者UDP协议",
|
||||||
|
protocolPort1:"只有tcp,udp协议端口号可以不为0"
|
||||||
});
|
});
|
||||||
}(jQuery));
|
}(jQuery));
|
||||||
|
|||||||
@@ -538,6 +538,10 @@ $(function(){
|
|||||||
$("#messageBox .close").on("click",function(){
|
$("#messageBox .close").on("click",function(){
|
||||||
heightDiv(1);
|
heightDiv(1);
|
||||||
})
|
})
|
||||||
|
//协议端口加入验证
|
||||||
|
$("input[name$='srcPort']").addClass("protocolPort");
|
||||||
|
$("input[name$='destPort']").addClass("protocolPort");
|
||||||
|
$("select[name$='protocol']").addClass("protocolPort");
|
||||||
});
|
});
|
||||||
window.onload=function(){
|
window.onload=function(){
|
||||||
$("span[id^=open]").click(function(){
|
$("span[id^=open]").click(function(){
|
||||||
|
|||||||
Reference in New Issue
Block a user