Hello I would like to know if it is possible to trigger an event on a form field
For example I have a name field in a form
I would like the error message to disappear when the person starts to fill in the field
But if the person removes the characters the error message comes back
Without any form validation
As you can see on my code for now I check the field on mouseover
function myFunction() {
const ville = document.querySelector('[name="ville"]');
if (ville !== null && ville.value !== '')
{
document.getElementById("myImgaa").src = "https://www.w3schools.com/jsref/img_pulpit.jpg";
} else {
document.getElementById("myImgaa").src = "";
}
}
<h1>HTML DOM Events</h1>
<h2>The onmousemove Event</h2>
<input class="form-control" type="text" name="ville" value="" id="ville" placeholder="" required="required" />
<div style ="width: 200px;
height: 100px;
border: 1px solid black;"onmousemove="myFunction(event)" ></div>
<img id="myImgaa" src="" width="107" height="98">