Jump to content

Script Pentru Afisarea Nr. De Cuvinte Ramase


gaby

Recommended Posts

Scriptul de mai jos, stabileste si verifica numarul de cuvinte introduse intr-un camp textarea, afiseaza numarul de cuvinte scrise, iar daca acest numar este depasit, se afiseaza o fereastra de atentionare.

Introduceti in sectiunea HEAD a documentul HTML, urmatorul script:

<script type="text/javascript">
<!--
// De MarPlo (http://www.marplo.net)

function verifica(text) {

 // Aici schimbati numarul maxim de cuvinte
 var maxwords=5;
 var nrc=text.value.split(" ");    // Imparte sirul in functie de caracterul spatiu
 // Verifca daca a fost depasit nr. maxim de cuvinte
 if (nrc.length>maxwords) {
   alert("Va rog adaugati maxim "+maxwords+" cuvinte!")
   return false
 }
 // Afiseaza nr. de cuvinte adaugate
 else {
   document.getElementById("countdown").innerHTML = 'Cuvinte adaugate <b>'+nrc.length+'</b> din maxim <u>'+maxwords+'</u>';
   return true
 }
}
//-->
</script> [/code] Dupa <body> adaugati urmatoarele linii:
[code]<form action="#" name="f" onsubmit="return verifica(document.f.ctest)">
<strong>Adaugati cuvinte cheie</strong><br>
(<i><span id="countdown">Folositi maxim 5 cuvinte</span></i>)<br>
<textarea rows="5" cols="38" name="ctest" onkeydown="verifica(this.value)" onkeyup="verifica(this)"></textarea><br>
<input type="submit" value="Trimite"> &nbsp; &nbsp;
<input type="reset" value="Sterge" name="sterge">
</form>

Succes :pct:

Te-ai inregistrat? Ne-ar placea sa te prezinti.

Cum pot sustine forumul?
Cumpara de la eMag folosind acest link.
--------------------
oG2BN9d.gifse1WdXd.gifQG6MtmI.gifRHYjDzD.gifG5p1wui.gif

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.