forgot to commit javascript changes, so added in check for in error visible before attempting to remove CSS class

This commit is contained in:
Robert McGovern 2022-09-29 10:01:45 +01:00
parent 03afd40b57
commit a65a624dfc
1 changed files with 16 additions and 7 deletions

View File

@ -20,10 +20,12 @@ function checkFormValidity(event) {
// console.log(`${input.id} is invalid`); // console.log(`${input.id} is invalid`);
// console.log(`${input.id} msg ${input.validationMessage}`); // console.log(`${input.id} msg ${input.validationMessage}`);
// get the relevant error message element, using id of the input // get the relevant error message element, using id of the input
let errorSection = document.getElementById(`errorMessage-${input.id}`) let errorSection = document.getElementById(
`errorMessage-${input.id}`
);
// console.log(`ES: ${errorSection}, ${typeof (errorSection)} id: ${errorSection.id}`); // console.log(`ES: ${errorSection}, ${typeof (errorSection)} id: ${errorSection.id}`);
errorSection.removeAttribute("hidden"); errorSection.hidden = false;
input.classList.add("error-highlight") input.classList.add("error-highlight");
} }
} }
} }
@ -32,8 +34,15 @@ function checkFormValidity(event) {
// I could more ideally check if the class is in the classlist, // I could more ideally check if the class is in the classlist,
// and attribute hidden was false // and attribute hidden was false
function inputFocused(event) { function inputFocused(event) {
/**
* Just for VS Code intellisense
*
* @type {HTMLInputElement}
*/
const input = event.currentTarget; const input = event.currentTarget;
input.classList.remove("error-highlight"); if (input.classList.contains("error-highlight")) {
let errorSection = document.getElementById(`errorMessage-${input.id}`); input.classList.remove("error-highlight");
errorSection.setAttribute("hidden", true); let errorSection = document.getElementById(`errorMessage-${input.id}`);
errorSection.hidden = true;
}
} }