It shows the error only in one field at a time, ie the part of "getElementById ('tuser')" and the other tpass, is the element of error. I wish that if both are null, show the error in both at once. However, I would like to use this same method.
Javascript:
function validate(){
if (document.formlog.usuario.value == ""){
document.getElementById('tuser').style = "display:block;";
return false;
}
if(document.formlog.senha.value == ""){
document.getElementById('tpass').style = "display:block;";
return false;
}
return true;
loader();
}
HTML (first part of code)
<form method="post" name="formlog" id="login-form" autocomplete="off" onsubmit="return(validate());" accept-charset="utf-8">