As follows:
The source code is as follows:
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ("Textarea"). keyup ();
});
Function strLenCalc (obj, checklen, maxlen ){
Var v = obj. val (), charlen = 0, maxlen =! Maxlen? 200: maxlen, curlen = maxlen, len = v. length;
For (var I = 0; I <v. length; I ++ ){
If (v. charCodeAt (I) <0 | v. charCodeAt (I)> 255 ){
Curlen-= 1;
}
}
If (curlen> = len ){
$ ("#" Upload checklen#.html ("You can also enter <strong>" + Math. floor (curlen-len)/2) + "</strong> words" ).css ('color ','');
$ ("# SubBtn"). removeAttr ("disabled ");
} Else {
$ ("#" Pipeline checklen#.html ("exceeds <strong>" + Math. ceil (len-curlen)/2) + "</strong> words" ..css ('color', '# ff0000 ');
$ ("# SubBtn"). attr ("disabled", "disabled ");
}
}
</Script>
<Textarea tabindex = "11" onkeyup = "strLenCalc ($ (this), 'checklen', 80 ); "value =" "class =" px "name =" subject "id =" subject "> </textarea>
<Span id = "checklen"> You can also enter <strong> 40 </strong> Chinese characters </span>
<Input type = "submit" id = "subBtn" value = "publish"/>