add login btn

This commit is contained in:
Liang Ding 2014-12-15 11:32:33 +08:00
parent 00f5c01aeb
commit 9c91c49f25
2 changed files with 18 additions and 6 deletions

View File

@ -65,7 +65,7 @@
.content .form {
width: 320px;
margin-top: 28px;
margin-top: -18px;
position: relative;
}
@ -161,4 +161,8 @@
#signUpBtn {
margin-top: 20px;
}
#loginBtn {
margin-top: 20px;
}
/* end sign up */

View File

@ -31,6 +31,7 @@
<div id="msg" class="fn-none"></div>
<input id="username" placeholder="Username"/><br/>
<input id="password" type="password" placeholder="Password"/><br/>
<button id="loginBtn" class="button">{{.i18n.login}}</button>
</div>
</div>
</div>
@ -48,21 +49,24 @@
.css("padding-top", (contentH - $(".content .fn-left").height()) / 2 + "px");
var login = function () {
if ($.trim($("#username").val()) === "") {
var username = $.trim($("#username").val());
var password = $.trim($("#password").val());
if (username === "") {
$("#msg").text("{{.i18n.login_error}}").show();
$("#username").focus();
return false;
} else if ($.trim($("#password").val()) === "") {
} else if (password === "") {
$("#msg").text("{{.i18n.login_error}}").show();
$("#password").focus();
return false;
}
var request = {
username: $("#username").val(),
password: $("#password").val()
username: username,
password: password
};
$.ajax({
type: 'POST',
url: '/login',
@ -103,6 +107,10 @@
$("#msg").hide();
}
});
$("#loginBtn").click(function () {
login();
});
})();
</script>
</body>