There is a specific line of code that I need help with.
document.getElementById("firstName").addEventListener("blur", validateField);
Additionally, there is this block of code:
validateField = (event) =>
{
const el = event.target;
}
My goal now is to invoke the validateField() function along with the corresponding element in the
form.addEventListener('submit', function(event)
section.
document.getElementById("firstName").blur(); // I am unable to make this call.
Unfortunately, directly using blur() does not seem to be effective in this case.
The main objective is to display the bootstrap is-invalid message when the form is submitted and remains invalid.
el.classList.add('is-invalid');
el.nextElementSibling.innerHTML = "This field is required";
I am aiming to avoid utilizing jQuery as I might transition this to bootstrap version 5 in the near future.