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

View File

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