Focus on fields in the login form

This just makes life a little easier...

Squashed the following commits:

* Use $.trim() for better browser support
This commit is contained in:
Richard Willis 2015-08-27 22:06:14 +02:00
parent b2dfdc386a
commit f26c0b71d2
1 changed files with 16 additions and 2 deletions

View File

@ -57,11 +57,15 @@ sudo tools/mail.py user make-admin me@{{hostname}}</pre>
<script>
function do_login() {
if ($('#loginEmail').val() == "") {
show_modal_error("Login Failed", "Enter your email address.")
show_modal_error("Login Failed", "Enter your email address.", function() {
$('#loginEmail').focus();
});
return false;
}
if ($('#loginPassword').val() == "") {
show_modal_error("Login Failed", "Enter your email password.")
show_modal_error("Login Failed", "Enter your email password.", function() {
$('#loginPassword').focus();
});
return false;
}
@ -126,4 +130,14 @@ function do_logout() {
sessionStorage.removeItem("miab-cp-credentials");
show_panel('login');
}
function show_login() {
$('#loginEmail,#loginPassword').each(function() {
var input = $(this);
if (!$.trim(input.val())) {
input.focus();
return false;
}
});
}
</script>