为什么校验不好使
代码如下
//初始化校验
$("#deptAddForm").validationEngine({
validationEventTrigger:'',
promptPosition:"centerRight"
});
//提交按钮
$("#submitBtn").click(function(){
var ss=$('#deptAddForm').validationEngine('validate');
//alert('ss='+ss);
//alert($('#parentId').val());
$.post(
"<%=basePath%>/back/privilege/deptLayout!update",{
rand: encryption(),
parentId:$('#parentId').val(),
name:$.trim($("#name").val()),
shortName:$.trim($("#shortName").val()),
seq:$('#seq').val(),
status:$('#status').val(),
flag:$('#flag').val(),
id:$('#id').val()
},function(json){
if(json.success){
alert('操作成功!');
var DG = frameElement.api;
DG.opener. refreshList();
}else{
alert(json.msg);
}
},'json'
);
});
//重置
$('#clearBtn').click(function() {
$('#deptAddForm')[0].reset() ;
$('#deptAddForm').validationEngine('hide');
});
});//html 代码<form action="<%=basePath%>/back/privilege/deptLayout!update" name="deptAddForm" id="deptAddForm">
<input type="hidden" id="parentId" name="parentId" value="<s:property value='parentId'/>" />
<input type="hidden" id="id" name="id" value="<s:property value='id'/>"/>
<input type="hidden" id="flag" name="flag" value="1"/>
<input type="hidden" id="status" name="status" value="1"/>
<tr>
<td align="right" width="39%" height="30">
所属部门:
</td>
<td align="left">
<input style="width: 122px;" type="text" id="deptName" name="deptName"
class="validate[required]" value="<s:property value='deptName'/>" readonly="readonly" />
<a id="menuBtn" href="javascript:void(0)">选择</a>
<span style="color: #FF0000" id="deptName_span"></span>
</td>
</tr>
<tr>
<td align="right" width="39%" height="30">
部门全称:
</td>
<td width="61%">
<input type="text" name="name" id="name"
class="validate[required,maxSize[30]]" value="<s:property value='name'/>" />
<span style="color: red; padding-left: 2px; padding-top: 13px;">*</span>
</td>
</tr>
<tr>
<td align="right" width="39%" height="30">
部门简称:
</td>
<td width="61%">
<input type="text" name="shortName" id="shortName"
class="validate[required,maxSize[10]]" value="<s:property value='shortName'/>" />
<span style="color: red; padding-left: 2px; padding-top: 13px;">*</span>
</td>
</tr>
<tr>
<td align="right" width="39%" height="30">
排 序:
</td>
<td width="61%">
<input type="text" name="seq" id="seq" value="<s:property value='seq'/>"
class="validate[custom[onlyNumberSp,max[127]]]" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<div style="display:none">
<input type="button" class="submit" name="submitBtn" id="submitBtn" value="提交" />
<input type="button" name="clearBtn" id="clearBtn" value="重置" />
</div>
</td>
</tr>
</form>
代码如下
//初始化校验
$("#deptAddForm").validationEngine({
validationEventTrigger:'',
promptPosition:"centerRight"
});
//提交按钮
$("#submitBtn").click(function(){
var ss=$('#deptAddForm').validationEngine('validate');
//alert('ss='+ss);
//alert($('#parentId').val());
$.post(
"<%=basePath%>/back/privilege/deptLayout!update",{
rand: encryption(),
parentId:$('#parentId').val(),
name:$.trim($("#name").val()),
shortName:$.trim($("#shortName").val()),
seq:$('#seq').val(),
status:$('#status').val(),
flag:$('#flag').val(),
id:$('#id').val()
},function(json){
if(json.success){
alert('操作成功!');
var DG = frameElement.api;
DG.opener. refreshList();
}else{
alert(json.msg);
}
},'json'
);
});
//重置
$('#clearBtn').click(function() {
$('#deptAddForm')[0].reset() ;
$('#deptAddForm').validationEngine('hide');
});
});//html 代码<form action="<%=basePath%>/back/privilege/deptLayout!update" name="deptAddForm" id="deptAddForm">
<input type="hidden" id="parentId" name="parentId" value="<s:property value='parentId'/>" />
<input type="hidden" id="id" name="id" value="<s:property value='id'/>"/>
<input type="hidden" id="flag" name="flag" value="1"/>
<input type="hidden" id="status" name="status" value="1"/>
<tr>
<td align="right" width="39%" height="30">
所属部门:
</td>
<td align="left">
<input style="width: 122px;" type="text" id="deptName" name="deptName"
class="validate[required]" value="<s:property value='deptName'/>" readonly="readonly" />
<a id="menuBtn" href="javascript:void(0)">选择</a>
<span style="color: #FF0000" id="deptName_span"></span>
</td>
</tr>
<tr>
<td align="right" width="39%" height="30">
部门全称:
</td>
<td width="61%">
<input type="text" name="name" id="name"
class="validate[required,maxSize[30]]" value="<s:property value='name'/>" />
<span style="color: red; padding-left: 2px; padding-top: 13px;">*</span>
</td>
</tr>
<tr>
<td align="right" width="39%" height="30">
部门简称:
</td>
<td width="61%">
<input type="text" name="shortName" id="shortName"
class="validate[required,maxSize[10]]" value="<s:property value='shortName'/>" />
<span style="color: red; padding-left: 2px; padding-top: 13px;">*</span>
</td>
</tr>
<tr>
<td align="right" width="39%" height="30">
排 序:
</td>
<td width="61%">
<input type="text" name="seq" id="seq" value="<s:property value='seq'/>"
class="validate[custom[onlyNumberSp,max[127]]]" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<div style="display:none">
<input type="button" class="submit" name="submitBtn" id="submitBtn" value="提交" />
<input type="button" name="clearBtn" id="clearBtn" value="重置" />
</div>
</td>
</tr>
</form>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货