@UrbanskiDev
Posted
Hello Abhilash !
Congratulation for finishing your project
To remove the errors when the form is filled, you can use the same idea than you used for showing the errors !
The code you use to show an error :
document.querySelector(".def").classList.remove("error");
To remove an error, you just have to add the class again !
document.querySelector(".def").classList.add("error");
I hope it helps you, keep learning and happy coding !
@Chiku100
Posted
@UrbanskiDev Hi Laharl! Thanks for the reply. Is there any way I can remove the error as soon as I start typing?
@UrbanskiDev
Posted
@Chiku100
It is possible to remove the error as soon as you start typing !
For that, you can use the oninput event ! The event linked fires up as soon as the user type inside the input box.
I have found a documentation which can helps you to apply it :
A quick basic example could be :
HTML
<input id="firstname" name="firstame" type="text" placeholder="First Name" oninput=testLength(this.value)>
Javascript
function testLength(val){
if(val.length !== 0){
document.querySelector(".def").classList.add("error");
}
}
I hope it answer your question !
Marked as helpful
@Chiku100
Posted
@UrbanskiDev It's working. Thanks a lot for helping me out :)