موضوع اسكريپت شمارنده كلمات


اين كد به شما اجازه مي دهد كه كلمات يا كاراكترهايي را كه وارد يك فيلد متني مي كنيد شمارش كنيد و براي آن يك حد نصاب تعريف كنيد .

 

< !-- TWO STEPS TO INSTALL WORD COUNTER:

1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -- >

< !-- STEP ONE: Paste this code into the HEAD of your HTML document -- >

< HEAD >

< SCRIPT LANGUAGE="JavaScript" >

< !-- This script and many more are available free online at -- >
< !-- The JavaScript Source!! http://WWW.OSTADONLINE.com -- >

< !-- Begin
var submitcount=0;
function checkSubmit() {

if (submitcount == 0)
{
submitcount++;
document.Surv.submit();
}
}


function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ") {wordcounter++} // Counts the spaces while ignoring double spaces, usually one in between each word.
if (wordcounter > 250) {field.value = field.value.substring(0, x);}
else {countfield.value = maxlimit - wordcounter;}
}
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
{field.value = field.value.substring(0, maxlimit);}
else
{countfield.value = maxlimit - field.value.length;}
}
// End -- >
< /script >

< /HEAD >

< !-- STEP TWO: Copy this code into the BODY of your HTML document -- >

< BODY >

< !-- This script and many more are available free online at -- >
< !-- The JavaScript Source!! http://www.ostadonline.com -- >

< FORM NAME=Surv >
< TABLE BORDER="0" CELLSPACING="0" CELLPADDING="3" width=550 >
< tr>< td valign="top" >
< font color="000000" size="2" face="verdana, helvetica, arial" >In 100 < b >words< /b > or less, why do you (or would you) like living on the coast?< /font >< font color="ff0000" size="2" face="verdana, helvetica, arial" >*< /font >
< td valign="top" >< textarea name="Q3367" cols="40" rows="5" wrap="hard" onKeyDown="wordCounter(this.form.Q3367,this.form.remLen,100);" onKeyUp="wordCounter(this.form.Q3367,this.form.remLen,100);" >< /textarea >
< br >Words remaining: < input type=box readonly name=remLen size=3 value=100 >< /td >< /tr >

< tr >< td colspan=2 >< hr width=80% >< /td >< /tr >

< tr >< td valign="top" >
< font color="000000" size="2" face="verdana, helvetica, arial" >In 100 < b >characters< /b > or less, why do you (or would you) like living on the coast?< /font >< font color="ff0000" size="2" face="verdana, helvetica, arial" >*< /font >
< td valign="top" >
< textarea name="Q336" cols="40" rows="5" wrap="hard" onKeyDown="textCounter(this.form.Q336,this.form.remLentext,100);" onKeyUp="textCounter(this.form.Q336,this.form.remLentext,100);" >< /textarea >
< br >Characters remaining: < input type=box readonly name=remLentext size=3 value=100 >
< /td >< /tr >
< /TABLE >

< INPUT TYPE="button" VALUE="Submit" onclick='' name=submit1 >
< INPUT TYPE="reset" VALUE="Reset" id=reset1 name=reset1 >
< /FORM >
< P >
< FONT SIZE="-2" COLOR="ff0000" FACE="verdana, helvetica, arial" >*< /FONT >< FONT SIZE="-2" COLOR="4169e1" FACE="verdana, helvetica, arial" Indicates a required question.< /FONT >



< p >< center >
< font face="arial, helvetica" size"-2" >Free JavaScripts provided by ostadonline< br >


< !-- Script Size: 3.38 KB -- >