login.jsp
<script type="text/javascript"> function gologin(form,callback) { // if("" == $("#accountCode").val()) { document.getElementById("ids").innerHTML= "请输入工号!"; return false; } else { document.getElementById("ids").innerHTML= ""; } // if("" == $("#accountPassword").val()) { document.getElementById("ids").innerHTML= "请输入密码!"; return false; } else { document.getElementById("ids").innerHTML= ""; } if ("" == $("#imgCode").val()) { document.getElementById("ids").innerHTML= "请输入图片验证码!"; return false; } else { document.getElementById("ids").innerHTML= ""; } //验证账号密码是都为空 if("" == $("#telephone").val() || "" == $("#accountPassword").val()) { document.getElementById("ids").innerHTML= "您的手机号码或密码输入不正确!"; return false; } else { document.getElementById("ids").innerHTML= ""; } //获取表单 var $form = $(form); $.ajax({ type: form.method || 'POST', url:$form.attr("action")+"&accountCode="+$("#accountCode").val()+"&imgCode="+$("#imgCode").val(), data:{accountPassword:$("#accountPassword").val()}, //data:$form.serializeArray(), dataType:"json", cache: false, success: function(data) { if('200' == data.statusCode) { $("#successForm").submit(); } else { document.getElementById("ids").innerHTML= data.message; } }, error: function(data){ alertMsg.error(data); } }); return false; } // 点击换验证码 function reflashImgCode() { $("#codeImg").attr("src",$("#codeImg").attr("src") +"?random="+Math.random); } </script> </head> <body> <form method="post" action="${rc.contextPath}/login/loginManager.htm?indet=log"(正常action提交) onsubmit="return gologin(this,'')" 表单提交返回方法 class="pageForm required-validate" id="login"> </form> <form method="post" action="${rc.contextPath}/login/loginSuccess.htm?indet=log" id="successForm"></form> </body> </html>