JS Code:
$ (function () {varCounter = $ ("#divform textarea"). val (). length;//gets the string length of the text field$("#gptu var"). Text (289-counter); $ (document). KeyUp (function () {varText = $ ("#divform textarea"). Val (); varCounter =text.length; if(Counter >289) { varQie = text.substring (0,289); Alert ("exceeds the maximum limit of 300 characters, the excess will be intercepted! "); $("#divform textarea"). Val (Qie); $("#gptu var"). Text ("0");//subtract character length each time } Else { $("#gptu var"). Text (289-counter);//subtract character length each time } }); });
HTML code:
<DivID= "Divform"> <textareaID= "Txt_content"name= "Txt_content"class= "NN Input_text"cols= " the"rows= "2"style= "width:90%; height:80px;"></textarea> <PID= "Gptu">You can also enter<varstyle= "COLOR: #C00">--</var>a character.</P> <P> </Div>
Jquery hint can also enter the number of words, the extra words to intercept