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
-
Inversare caractere adăugate într-un câmp de text
JavaScript - jQuery - Ajax
Primul mesaj
Am urmatorul cod html si JavaScript. O caseta de text input si un button.
<input type='text' id='backwards-input'>
<button...
Ultimul mesaj
Testeaza si studiaza urmatorul cod:
<input type='text' id='backwards-input'>
<button id='backwards-button'>Button</button>...
-
Ascunde element daca in data e un anumit text
HTML - XHTML - CSS
Primul mesaj
Se pot ascunde elemente HTML daca in atributul 'data-' e o anumita bucata de text?
De exemplu: Ascunde Div-urile care contin -en .
<div...
Ultimul mesaj
Se poate face cu CSS sau cu Javascript.
CSS:
/* with specified elements */
div {
display: none;
}
/* or global */
{
display: none;
}
Si...