Skip to content

Commit

Permalink
check that label isn't blank when using it for error message
Browse files Browse the repository at this point in the history
  • Loading branch information
TomJLynch committed Mar 2, 2018
1 parent 5fee9de commit cf01b90
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/metron.forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (<HTMLElement>f.selectOne(`label[for='${elem.attribute("id")}']`)).innerText != "") {
result += `<p>${(<HTMLElement>f.selectOne(`label[for='${elem.attribute("id")}']`)).innerText} is a required field.</p>`;
} else {
result += `<p>[${elem.attribute("name")}] is a required field.</p>`;
Expand Down

0 comments on commit cf01b90

Please sign in to comment.