functie verificare cod din text box

Discutii si intrebari legate de scripturi si functii JavaScript, jQuery si Ajax, cod JavaScript in general.
keenbr
Mesaje: 44

functie verificare cod din text box

Salut... vreau sa fac o verificare dar nu prea imi iese :-|

Functie JS:

Cod: Selectaţi tot

function verific(code) {
	var capcha = document.getElementById("capcha").value;
	var code = document.getElementById("code").innerHTML;
    if (capcha == code) {
	document.getElementById('notification').style.display = 'hidden';
    }
	else {
    document.getElementById('notification').style.display = 'inline';
    }	
}
Formular:

Cod: Selectaţi tot

<?php
print "Cod securitate: ";

$md5 = md5(microtime() * mktime());
$string = substr($md5,0,5);
$_SESSION['capcha']=$string;
$code=$_SESSION['capcha'];

print " <span id='code'>";
print $_SESSION['capcha'];
print "</span>";
print "<br/>";
print "<input type='text' name='capcha' id='capcha' size='10' onkeyup=\"verific()\">";
print "<span id='notification' style='display:none; color: red; weight: bold;'> Codul de securitate este incorect!</span>";
print "<br/><br/>";
?>
Problema e ca rezultatul e mereu acelasi... adica incorect desi il pun corect.

MarPlo Mesaje: 4343
Salut,
Pentru a ascunde un element cu proprietatea "display", se foloseste valoarea "none".
In codul tau, in functia JavaScript ar trebui:

Cod: Selectaţi tot

document.getElementById('notification').style.display = 'none';

keenbr Mesaje: 44
a mers... multam fain

Subiecte similare