jquery validate 前端验证,有时生效,有时不生效,求助!

sspanzervor1 sspanzervor1 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
代码很简单,用jquery对查询起止日期进行判断,如下组合,在我其它页面上验证均无问题,并且在本页面的另外一个表单验证也正常,但是奇怪的是,在这个表单里,执行就是时好时坏,有时候可以出现错误提示,验证正常进行进行,有时候验证直接被跳过去(即不管前端验证成功与否,全部跳到结果界面!!! 这样会导致查询结果为空,已经弄了两天还是没解决,请各位前辈帮忙看看吧,多谢多谢!

引用jquery库:

<script src="jquery-ui-1.9.2.custom/js/jquery-1.8.3.js"></script>
<script src="jquery-ui-1.9.2.custom/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="jquery-ui-1.9.2.custom/development-bundle/ui/jquery.ui.datepicker.js"></script>
<script src="jquery/dist/jquery.validate.js"></script>
<script src="jquery/dist/localization/messages_zh.js"></script>
<script src="jquery/jquery_validate_extended.js"></script>
<script src="jquery/jquery_datapicker_validation/jquery.ui.datepicker.validation.js"></script>
<script src="jquery-ui-1.12.1.custom/jquery.form.js"></script>

<script src="jquery/jquery.simplemodal-1.4.4.js"></script>


jquery验证代码:

	
$("#frm1").validate({
errorElement:'span',
//debug: true,
rules: {
txt_startdate: {required:true},
txt_enddate: {required:true, compareDate: true},
},
messages: {
txt_startdate: {required: "请选择起始日期!"},
txt_enddate: {required: "请选择结束日期!", compareDate:"起始日期不能大于结束日期!"},
},

errorPlacement: function(error, element) {
alert('aaa');
error.appendTo(element.parent());
},
/* 2019-5-7 如果这一表单无须返回值,这部分应省略掉;如不省略,前端认证会不生效*/
submitHandler: function(form){
//form.submit();
}

});


部分HTML代码如下:
用了 jquery的SimpleModal 框架:

<div id='container'>
<form class="FT_form" id="frm1" name="frm1" method="post" action="ftt_ward_results.asp">
<TABLE border=0 cellPadding=0 cellSpacing=0 style="width:100%; overflow:scroll">
<thead>
<tr>
<td id="tdTop" name="tdTop" colspan="3">
<span id="spLog" name="spLog">当前登录用户:<%=request.Cookies("ftt_uid")%></span>
<span id="spRelog" name="spRelog"><a href="ftt_login.asp">重新登录</a></span>
</td>
</tr>
</thead>
<tbody>
<tr>
<td align="center" valign="middle" id="tdNav" name="tdNav" nowrap>
<iframe id="frmNav" name="frmNav" frameborder="0" src="ftt_navLeft.asp"></iframe>
</td>

<td name="tdPoint" id="tdPoint" align="center" valign="middle" onClick="aaa();" nowrap
style="vertical-align:top; padding-top:300px;">
<span class="navPoint" id="switchPoint">3</span>
</td>
<td id="tdMain" valign="top">

<table id="tbl_info">
<tr style="background-color:#0056a5; border:1px solid #666; color:white; font-weight:bold; text-height:30px; height:30px;">
<td colspan="10" style="text-align:left">客房入住情况查询 - 起止日期选择</td>
</tr>
<tr style="text-align:left;">
<td colspan="10" style="text-align:left;">

<label for="lbl1" style="margin-left:5px; margin-right:2px;">从</label>
<input type="text" name="txt_startdate" id="txt_startdate">
<label for="lbl2" style="margin-left:15px; margin-right:2px;">至</label>
<input type="text" name="txt_enddate" id="txt_enddate">
<button class="submit" type="button" name="btn_search" id="btn_search" value="submit"
onClick="form.submit();">查询</button>
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</form>
</div>


...全文
评论 4
收藏 已收藏
分享
返回顶部
sspanzervor1
JavaScript 87,983 成员 224,681 内容