Witam,
Chciałem napisać skrypt js, który zmienia atrybut "display" (css) danego id w zależności, czy pole w formularzu zostało wypełnione, ale coś mi nie działa. Poniżej podam kod, a jak ktoś znajdzie błąd, to proszę łaskawie o odpowiedź:
function walid_logowanie(form)
{
var error_log='';
if (form.login.value==""){
error_log=error_log+'- Login,\n';
document.getElementById(walid_login).style.display = block;
}
if (form.password.value=="")
{
error_log=error_log+'- Hasło.\n';
alert ('pass');
document.getElementById(walid_password).style.display = block;
}
if (error_log!='') {
alert ('Nie wypełniono następujących pól:\n'+error_log);
return false;
} else {
return true;
}
<form onsubmit="return walid_logowanie(this);" method="POST" action="index.html" > <td><input type="text" name="login" size="20"></td> <td><div id="walid_login" style="display: none; height: 25px; width: 25px; background: url(style_imgs/x25px.png) no-repeat;">Wypełnij to pole
</div></td> <td><input type="password" name="password" size="20"></td> <td><div id="walid_password" style="display: none; height: 25px; width: 25px; background: url(style_imgs/x25px.png) no-repeat;">Wypełnij to pole
</div></td> <td><input class="zaloguj" type="submit" value="ZALOGUJ"></td>
Już mi się udało. Temat do kosza
Ten post edytował Brotchier 10.10.2011, 12:10:37