Skip to content

Commit 4e2d24b

Browse files
committed
Validation added for topic
1 parent 3dfcbf4 commit 4e2d24b

File tree

1 file changed

+10
-3
lines changed
  • DigitalLearningSolutions.Web/Scripts/frameworks

1 file changed

+10
-3
lines changed

DigitalLearningSolutions.Web/Scripts/frameworks/branding.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,34 @@ function topicChanged() {
5050
if (style === 'block') {
5151
tb.value = '';
5252
tb.required = true;
53+
tb.setCustomValidity("");
5354
tb.focus();
5455
} else {
56+
tb.value = "";
57+
tb.setCustomValidity("");
5558
tb.required = false;
5659
}
5760
}
5861
const form = document.querySelector("form") as HTMLFormElement;
5962
const bfield = <HTMLInputElement>document.getElementById('brand-field');
6063
const cfield = <HTMLInputElement>document.getElementById('category-field');
64+
const tfield = <HTMLInputElement>document.getElementById('topic-field');
6165
function wireClearOnInput(input: HTMLInputElement) {
6266
input.addEventListener("input", () => {
6367
input.setCustomValidity("");
6468
});
6569
}
6670

67-
wireClearOnInput(bfield);
68-
wireClearOnInput(cfield);
71+
if (bfield) wireClearOnInput(bfield);
72+
if (cfield) wireClearOnInput(cfield);
73+
if (tfield) wireClearOnInput(tfield);
74+
6975

7076
form.addEventListener("submit", (e: Event) => {
7177
const fields = [
7278
{ el: bfield, msg: "Please enter a valid brand." },
73-
{ el: cfield, msg: "Please enter a valid category." }
79+
{ el: cfield, msg: "Please enter a valid category." },
80+
{ el: tfield, msg: "Please enter a valid topic." }
7481
];
7582

7683
for (const f of fields) {

0 commit comments

Comments
 (0)