diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/jquery.validate.method.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/jquery.validate.method.js index d3501d636..fb95cefa0 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/jquery.validate.method.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/jquery.validate.method.js @@ -208,7 +208,44 @@ jQuery.validator.addMethod("httpCheck",function(value, element) { } 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地址校验 jQuery.validator.addMethod("ipCheck",function(value, element) { diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js index ac543bf5c..47a04a579 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js @@ -72,6 +72,8 @@ go_back:"Go Back Policies", log_5_minutes:"Log For The Last Five Minutes", 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)); diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js index 0705c405e..76fc2ca1b 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js @@ -72,6 +72,8 @@ go_back:"Go Back Policies", log_5_minutes:"Log For The Last Five Minutes", 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)); diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js index 5c9ea8ada..9690dd0ea 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js @@ -72,6 +72,8 @@ go_back:"返回配置界面", log_5_minutes:"5分钟日志量", log_1_hour:"1小时日志量", - input:"请输入 " + input:"请输入 ", + protocolPort:"端口大于0时必须选择TCP协议或者UDP协议", + protocolPort1:"只有tcp,udp协议端口号可以不为0" }); }(jQuery)); diff --git a/src/main/webapp/static/global/scripts/common.js b/src/main/webapp/static/global/scripts/common.js index 38ea8700b..7cd21481c 100644 --- a/src/main/webapp/static/global/scripts/common.js +++ b/src/main/webapp/static/global/scripts/common.js @@ -538,6 +538,10 @@ $(function(){ $("#messageBox .close").on("click",function(){ heightDiv(1); }) + //协议端口加入验证 + $("input[name$='srcPort']").addClass("protocolPort"); + $("input[name$='destPort']").addClass("protocolPort"); + $("select[name$='protocol']").addClass("protocolPort"); }); window.onload=function(){ $("span[id^=open]").click(function(){