|
|
@@ -32,7 +32,7 @@
|
|
|
<img class="img-code" onclick="changePic()" id="img-code" src="http://htt.55128.cn/Util/VerifyCode?0.49822945461860857" alt="">
|
|
|
</div>
|
|
|
<div class="form-button">
|
|
|
- <button id="btn">登录</button>
|
|
|
+ <button id="btn" onclick="submitForm()">登录</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -62,12 +62,12 @@
|
|
|
return;
|
|
|
}
|
|
|
})
|
|
|
- $("#btn").on("click",function() {
|
|
|
+ function submitForm() {
|
|
|
var username = $.trim($("#username").val());
|
|
|
var pwd = $.trim($("#pwd").val());
|
|
|
var code = $.trim($("#code").val());
|
|
|
var uregs = /^[a-zA-Z0-9]{4,12}$/
|
|
|
- var pregs = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/
|
|
|
+ var pregs = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/;
|
|
|
if(!uregs.test(username) || username == ''){
|
|
|
layer.tips('请输入正确的用户名格式',$("#username"));
|
|
|
$("#username").focus();
|
|
|
@@ -90,16 +90,74 @@
|
|
|
}
|
|
|
$.ajax({
|
|
|
type:'post',
|
|
|
- url:'',
|
|
|
+ url:'/Login/CheckLogin',
|
|
|
dataType:'json',
|
|
|
- data:{'username':username,'pwd':pwd,'code':code},
|
|
|
+ data: { 'username': username, 'password': pwd,'verifycode':code},
|
|
|
success:function(res) {
|
|
|
- if(res.code == 0) {
|
|
|
- window.location.href = './index.html'
|
|
|
+ if (res.code == 0) {
|
|
|
+ window.location.href = '/Login/Index';
|
|
|
+ } else {
|
|
|
+ layer.msg("登录失败", { icon: 5 });
|
|
|
+ changePic();
|
|
|
+ $("#code").val("");
|
|
|
}
|
|
|
+ },
|
|
|
+ error:function() {
|
|
|
+ layer.msg("登录失败", { icon: 6 });
|
|
|
+ changePic();
|
|
|
+ $("#code").val("");
|
|
|
}
|
|
|
})
|
|
|
+ }
|
|
|
+
|
|
|
+ $(function() {
|
|
|
+ document.onkeydown = function (e) { // 回车提交表单
|
|
|
+ var theEvent = window.event || e;
|
|
|
+ var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
|
|
|
+ if (code == 13) {
|
|
|
+ submitForm();
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
+
|
|
|
+ // $("#btn").on("click",function() {
|
|
|
+ // var username = $.trim($("#username").val());
|
|
|
+ // var pwd = $.trim($("#pwd").val());
|
|
|
+ // var code = $.trim($("#code").val());
|
|
|
+ // var uregs = /^[a-zA-Z0-9]{4,12}$/
|
|
|
+ // var pregs = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/
|
|
|
+ // if(!uregs.test(username) || username == ''){
|
|
|
+ // layer.tips('请输入正确的用户名格式',$("#username"));
|
|
|
+ // $("#username").focus();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // if(!pregs.test(pwd) || pwd == ''){
|
|
|
+ // layer.tips('请输入正确的密码格式',$("#pwd"));
|
|
|
+ // $("#pwd").focus();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // if(code == '') {
|
|
|
+ // layer.tips('请输入验证码',$("#code"));
|
|
|
+ // $("#code").focus();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // if(code.length != 4) {
|
|
|
+ // layer.tips('请输入合法的验证码',$("#code"));
|
|
|
+ // $("#code").focus();
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // $.ajax({
|
|
|
+ // type:'post',
|
|
|
+ // url:'',
|
|
|
+ // dataType:'json',
|
|
|
+ // data:{'username':username,'pwd':pwd,'code':code},
|
|
|
+ // success:function(res) {
|
|
|
+ // if(res.code == 0) {
|
|
|
+ // window.location.href = './index.html'
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
</script>
|
|
|
</body>
|
|
|
</html>
|