<form id="sb" action="${pageContext.request.contextPath }/admin/loanContract/addOrUpdate.do" method="post" onsubmit="submitTest();"> <div class="j_dd"> <div class="clearfix"> <span class="fTit left">交易订单号:</span><input type="text" class="txt left ui-autocomplete-input" id="tradeCode" name="tradeCode" onkeyup="value=value.replace(/[W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))" style="300px;"/>*<span style="color:red; display:block; padding-left:85px; clear:both; padding-top:5px;" id="sp" name="sp"></span> </div> <div class="clearfix" style="margin-top:10px"> <span class="fTit left">备注:</span> <textarea id="tradeIntro" name="tradeIntro" style="305px;"></textarea> </div> <div class="bigBox clearfix"> <button class="tjbtn" type="submit" id="sbm">提 交</button> <a href="${pageContext.request.contextPath }/admin/loanContract/loanItem.do?contents=platform" title="" class="tjbtn">取 消</a> </div> </form> <script type="text/javascript"> // Ajax校验数据库该交易订单是否已存在 var orderInfoConfirm = { modifyOrderInfo : function(){ $("#tradeCode").blur(function(){ var tradeCode = $("#tradeCode").val(); if(tradeCode ==""){ $("#sp").html("请输入交易订单号!"); return; } $.ajax({ url:"checkTradeCode.do", data:{tradeCode:tradeCode}, dataType:"json", success:function(data){ var arr = eval(data); $("#sp").html(arr.code); } }); }); }, submitTest : function(){ $("#sbm").click(function(){ if(tradeCode ==""){ $("#sp").html("请输入交易订单号!"); return false; } var sp = $("#sp").html(); if(sp == "交易订单已存在!"||sp == "请输入交易订单号!"){ return false; } else return true; }); } }; $(document).ready(function() { orderInfoConfirm.modifyOrderInfo(); orderInfoConfirm.submitTest(); }); </script>