增强配置表单校验
This commit is contained in:
@@ -9,7 +9,7 @@ $(function(){
|
||||
//$("[name^='stringCfg']").attr("disabled",true);
|
||||
//$("[name^='complexCfg']").attr("disabled",true);
|
||||
//$("[name^='numCfg']").attr("disabled",true);
|
||||
$(".glyphicon").on("click",function(){
|
||||
/* $(".glyphicon").on("click",function(){
|
||||
var className=$(this).attr("data-target");
|
||||
if($(this).hasClass("glyphicon-chevron-down")){
|
||||
$(this).removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up");
|
||||
@@ -29,6 +29,128 @@ $(function(){
|
||||
$(this).removeClass("glyphicon-remove").addClass("glyphicon-plus");
|
||||
$("[name^='"+targetName+"']").attr("disabled",true);
|
||||
}
|
||||
}); */
|
||||
$("#cfgFrom").validate({
|
||||
rules: {
|
||||
//基本配置校验开始
|
||||
'isAreaEffective':{
|
||||
required:true
|
||||
},
|
||||
'requestId': {
|
||||
required: true
|
||||
}
|
||||
//基本配置校验结束
|
||||
//maintable校验开始
|
||||
,
|
||||
'complexCfg[${mainTable}].district': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'complexCfg[${mainTable}].keywords': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'complexCfg[${mainTable}].exprType': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'complexCfg[${mainTable}].matchMethod': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'complexCfg[${mainTable}].isHexbin': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'stringCfg[${mainTable}].cfgKeywords': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'stringCfg[${mainTable}].exprType': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'stringCfg[${mainTable}].matchMethod': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'stringCfg[${mainTable}].isHexbin': {
|
||||
required: true
|
||||
}
|
||||
//maintable校验结束
|
||||
//othertable校验开始
|
||||
<c:forEach items="${_cfg.otherTables}" var="otherTable">
|
||||
,
|
||||
'complexCfg[${otherTable.tableName}].district': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'complexCfg[${otherTable.tableName}].keywords': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'complexCfg[${otherTable.tableName}].exprType': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'complexCfg[${otherTable.tableName}].matchMethod': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'complexCfg[${otherTable.tableName}].isHexbin': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'stringCfg[${otherTable.tableName}].cfgKeywords': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'stringCfg[${otherTable.tableName}].exprType': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'stringCfg[${otherTable.tableName}].matchMethod': {
|
||||
required: true
|
||||
}
|
||||
,
|
||||
'stringCfg[${otherTable.tableName}].isHexbin': {
|
||||
required: true
|
||||
}
|
||||
</c:forEach>
|
||||
//othertable校验结束
|
||||
},
|
||||
messages: {
|
||||
'isAreaEffective':{
|
||||
required:'<spring:message code="required"/>'
|
||||
},
|
||||
'requestId': {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
},
|
||||
errorPlacement: function(error,element){
|
||||
$(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error);
|
||||
},
|
||||
submitHandler: function(form){
|
||||
form.submit();
|
||||
},
|
||||
errorContainer: "#messageBox"
|
||||
});
|
||||
|
||||
$("#ipSelect").change(function(){
|
||||
if($(this).prop("checked")){
|
||||
$("[name^='ipCfg']").removeProp("disabled");
|
||||
//解决select插件disbale后无法恢复
|
||||
$(".bootstrap-select").removeClass("disabled");
|
||||
$(".bootstrap-select button").removeClass("disabled");
|
||||
$(".collapse").addClass("in");
|
||||
|
||||
myValidate(true);//开启ip校验
|
||||
}else{
|
||||
myValidate(false);//关闭ip校验
|
||||
|
||||
$(".collapse").removeClass("in");
|
||||
$("[name^='ipCfg']").attr("disabled",true);
|
||||
}
|
||||
});
|
||||
$(".district").on("change",function(){
|
||||
var val=$(this).val().toLowerCase();
|
||||
@@ -105,33 +227,149 @@ $(function(){
|
||||
$("#cancel").on("click",function(){
|
||||
window.history.back();
|
||||
});
|
||||
$("#cfgFrom").validate({
|
||||
rules: {
|
||||
'isAreaEffective':{
|
||||
required:true
|
||||
},
|
||||
'requestId': {
|
||||
required: true
|
||||
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
'isAreaEffective':{
|
||||
required:'<spring:message code="required"/>'
|
||||
},
|
||||
'requestId': {
|
||||
required: '<spring:message code="required"/>'
|
||||
}
|
||||
},
|
||||
errorPlacement: function(error,element){
|
||||
$(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error);
|
||||
},
|
||||
submitHandler: function(form){
|
||||
form.submit();
|
||||
},
|
||||
errorContainer: "#messageBox"
|
||||
});
|
||||
|
||||
myValidate();
|
||||
});
|
||||
|
||||
function myValidate(flag) {
|
||||
if (flag) {
|
||||
myValidate(false);
|
||||
$("#cfgFrom").validate();
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.ipType]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcIp]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcIpMask]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcPort]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcPortMask]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.dstIp]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.dstIpMask]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.dstPort]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.dstPortMask]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.direction]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.protocol]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.isAreaEffective]").each(function(){
|
||||
$(this).rules("add", {
|
||||
required: true,
|
||||
messages: {
|
||||
required:'<spring:message code="required"/>'
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.ipType]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcIp]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcIpMask]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcPort]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.srcPortMask]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.dstIp]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.dstIpMask]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.dstPort]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.dstPortMask]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.direction]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.protocol]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
$("[name=ipCfg\\[http_ip_cfg\\]\\.isAreaEffective]").each(function(){
|
||||
$(this).rules("remove");
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -189,6 +427,10 @@ $(function(){
|
||||
<c:when test="${otherTable.tableType eq '2'}">
|
||||
<%@include file="/WEB-INF/include/form/multiple/stringInfo.jsp" %>
|
||||
</c:when>
|
||||
</c:choose>
|
||||
</c:forEach>
|
||||
<c:forEach items="${_cfg.otherTables}" var="otherTable">
|
||||
<c:choose>
|
||||
<c:when test="${otherTable.tableType eq '1'}">
|
||||
<%@include file="/WEB-INF/include/form/multiple/ipInfo.jsp" %>
|
||||
</c:when>
|
||||
|
||||
Reference in New Issue
Block a user