From cf01b90125a391be07ce3524c37cb7d9337416c8 Mon Sep 17 00:00:00 2001 From: Tom Lynch Date: Fri, 2 Mar 2018 14:33:49 -0500 Subject: [PATCH] check that label isn't blank when using it for error message --- src/metron.forms.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/metron.forms.ts b/src/metron.forms.ts index fb7d3a7..f29da4e 100644 --- a/src/metron.forms.ts +++ b/src/metron.forms.ts @@ -268,6 +268,8 @@ namespace metron { elem.addClass("error"); if (f.selectOne(`label[for='${elem.attribute("id")}']`) != null) { f.selectOne(`label[for='${elem.attribute("id")}']`).addClass("label-error"); + } + if (f.selectOne(`label[for='${elem.attribute("id")}']`) != null && (f.selectOne(`label[for='${elem.attribute("id")}']`)).innerText != "") { result += `

${(f.selectOne(`label[for='${elem.attribute("id")}']`)).innerText} is a required field.

`; } else { result += `

[${elem.attribute("name")}] is a required field.

`;