Urmatorul script stabileste si verifica numarul de caractere introduse intr-un textarea, afiseaza numarul de caractere ramase si daca acest numar este depasit afiseaza o fereastra alert de atentionare.
Puteti testa scriptul in campul de text de mai jos.
Pentru a adauga acest script intr-o pagina web:
<script type="text/javascript">
<!--
// De MarPlo (https://marplo.net)
function verifica(text) {
// Aici schimbati numarul maxim de caractere
var maxlength=80;
// Verifca daca a fost depasit nr. maxim de caractere
if (text.value.length>maxlength) {
alert("Va rog adaugati maxim "+maxlength+" caractere!")
return false
}
// Afiseaza nr. de caractere ramase
else {
document.getElementById("countdown").innerHTML = 'Mai aveti <b>'+(maxlength-text.value.length)+'</b> caractere';
return true
}
}
//-->
</script>
<form action="#" name="f" onsubmit="return verifica(document.f.ctest)">
<strong>Adaugati o scurta descriere</strong> (<i><span id="countdown">in maxim 80 caractere</span></i>)<br>
<textarea rows="5" cols="38" name="ctest" onkeydown="verifica(this)" onkeyup="verifica(this)"></textarea><br>
<input type="submit" value="Trimite">
<input type="reset" value="Sterge" name="sterge">
</form>
<div>Web Programming and Development</div>
h2 { text-decoration: underline; }
function someFunction() { alert("CoursesWeb.net"); } setTimeout("someFunction()", 2000);
$food =["fruits" =>["banana", "mar"), "veggie" =>["ceapa", "rosie")); $nr_food = count($food, 1); echo $nr_food; // 6
The child will haven't played by Sunday. - Copilul nu s-ar fi jucat pana duminica.
Él no habrá contado el cuento. - El nu ar fi spus povestea.