I have made a login and I made that when I hit the enter button it would show a gif of loading... and it shows it but if in any case they are not the correct credentials follow the gif, that is, I don't know how to stop it, the idea is to put something like this as an if so that it says that if it gives an error, the gif stops, how would that be implemented?
function loading(){
imagen = '<img src="./img/loading.gif"/>';
document.getElementById('loading2').innerHTML = imagen;
}
As your partner has told you, the best way to do it is by hiding it and showing it as you see fit. It would be something like this:
HTML
javascript
if you don't want to complicate, the easiest way would be to include the gif in your HTML, adding a "display:none;" when you click to log in you enable the display, and when you finish with all the checks, (whether they are valid credentials or not), you hide the gif again.
All the best.