diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 858fe246dda0f..5d6f4ee81aceb 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -813,6 +813,16 @@ M.util.focus_login_form = function(Y) { } } +/** + * Set focus on login error message + */ +M.util.focus_login_error = function(Y) { + var errorlog = Y.one('#loginerrormessage'); + + if (errorlog) { + errorlog.focus(); + } +} /** * Adds lightbox hidden element that covers the whole node. * diff --git a/login/index.php b/login/index.php index 1847544b75a09..4526ba6832aae 100644 --- a/login/index.php +++ b/login/index.php @@ -345,7 +345,9 @@ echo $OUTPUT->box_end(); } else { include("index_form.html"); - if (!empty($CFG->loginpageautofocus)) { + if ($errormsg) { + $PAGE->requires->js_init_call('M.util.focus_login_error', null, true); + } else if (!empty($CFG->loginpageautofocus)) { //focus username or password $PAGE->requires->js_init_call('M.util.focus_login_form', null, true); } diff --git a/login/index_form.html b/login/index_form.html index 1765064cd10e7..f7557a57e3f8c 100644 --- a/login/index_form.html +++ b/login/index_form.html @@ -30,9 +30,10 @@

'; + echo html_writer::start_tag('div', array('class' => 'loginerrors')); + echo html_writer::link('#', $errormsg, array('id' => 'loginerrormessage', 'class' => 'accesshide')); echo $OUTPUT->error_text($errormsg); - echo ''; + echo html_writer::end_tag('div'); } ?>
>