From f6ab97a886a32f5f18be619e4e0444cfba4e714d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Tue, 12 Sep 2017 00:44:49 +0200 Subject: [PATCH] improved error reporting in forms --- js/appcommon.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/appcommon.js b/js/appcommon.js index 08fc058..3b03ba7 100644 --- a/js/appcommon.js +++ b/js/appcommon.js @@ -78,18 +78,19 @@ $.ready(function () { let errAt = location.search.indexOf('err=') if (errAt !== -1 && qs('.Box.errors')) { let errs = location.search.substr(errAt + 4).split(',') - let hres = [] + let humanReadableErrors = [] errs.forEach(function (er) { let lbl = qs('label[for="' + er + '"]') if (lbl) { lbl.classList.add('error') - hres.push(lbl.childNodes[0].textContent.trim().replace(/: ?$/, '')) - } else { - hres.push(er) + humanReadableErrors.push(lbl.childNodes[0].textContent.trim().replace(/: ?$/, '')) } + // else { + // hres.push(er) + // } }) - qs('.Box.errors .list').innerHTML = hres.join(', ') + qs('.Box.errors .list').innerHTML = humanReadableErrors.join(', ') qs('.Box.errors').classList.remove('hidden') }