ldc-agis/resources/ts/fo/pages/joinus.ts
2023-12-19 15:09:12 +00:00

24 lines
870 B
TypeScript

document.addEventListener("DOMContentLoaded", function () {
const joinusPage = document.querySelector("section.joinus");
if (joinusPage === null) {
return;
}
// * Return string error.
function getErrorString(fieldName: string) {
return `Élement du dom ${fieldName} inexistant.`;
}
// * Get filename.
const inputFile = joinusPage.querySelector("input[name=\"file\"]") as HTMLSelectElement | null;
const renderFileName = joinusPage.querySelector("#input-file-name") as HTMLParagraphElement | null;
if (inputFile === null) {
throw new Error(getErrorString("input[name=\"file\"]"));
}
if (renderFileName === null) {
throw new Error(getErrorString("#input-file-name"));
}
inputFile.addEventListener("change", function () {
renderFileName.textContent = this.value;
});
});