From 790b3da848c0bc9e357e57ce904d0122d92094f6 Mon Sep 17 00:00:00 2001 From: Jason Fowler Date: Tue, 13 Aug 2013 15:10:35 +0800 Subject: [PATCH] MDL-30839 Accessibility, Forms - Improve accessibility or error messages --- lib/formslib.php | 9 ++++++--- theme/base/style/core.css | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/formslib.php b/lib/formslib.php index 29e05033ed5..a90d6207f10 100644 --- a/lib/formslib.php +++ b/lib/formslib.php @@ -1952,6 +1952,8 @@ function qf_errorHandler(element, _qfMsg) { errorSpan.id = \'id_error_\'+element.name; errorSpan.className = "error"; element.parentNode.insertBefore(errorSpan, element.parentNode.firstChild); + document.getElementById(errorSpan.id).setAttribute(\'TabIndex\', \'0\'); + document.getElementById(errorSpan.id).focus(); } while (errorSpan.firstChild) { @@ -1959,11 +1961,12 @@ function qf_errorHandler(element, _qfMsg) { } errorSpan.appendChild(document.createTextNode(_qfMsg.substring(3))); - errorSpan.appendChild(document.createElement("br")); if (div.className.substr(div.className.length - 6, 6) != " error" - && div.className != "error") { - div.className += " error"; + && div.className != "error") { + div.className += " error"; + linebreak = document.createElement("br"); + errorSpan.parentNode.insertBefore(linebreak, errorSpan.nextSibling); } return false; diff --git a/theme/base/style/core.css b/theme/base/style/core.css index 497da5c9039..3a91681d7dc 100644 --- a/theme/base/style/core.css +++ b/theme/base/style/core.css @@ -241,6 +241,7 @@ a.skip:active {position: static;display: block;} .dir-rtl .mform .fitem fieldset.felement {padding-right: 1%;margin-right: 15%;} .mform .error, .mform .required {color:#A00;} +.mform span.error {display: inline-block;padding: 4px;margin-bottom: 4px;background-color: #F2DEDE;border: 1px solid #EED3D7;} .mform .required .fgroup span label {color:#000;} .mform .fdescription.required {color:#A00;text-align:right;} .mform .fpassword .unmask {display:inline;margin-left:0.5em;}