I have also introduced a jquery plug-in with similar effects, jquery maxlength text limit plug-in. However, this charcount deployment is simpler, and it has the function of exceeding the number prompt.
Simple deployment:
1. Load JS: CopyCodeThe Code is as follows: <SCRIPT type = "text/JavaScript" src = "JS/jquery. js"> </SCRIPT>
<SCRIPT type = "text/JavaScript" src = "JS/charcount. js"> </SCRIPT>
2. HTML structure: copy Code the code is as follows:
default usage
type your message
Custom usage
another message (limited to 30, warning at 10)
3. charcount plug-in settings: Copy codeThe Code is as follows: <SCRIPT type = "text/JavaScript">
$ (Document). Ready (function (){
// Default usage
$ ("# Message1"). charcount ();
// Custom usage
$ ("# Message2"). charcount ({
Allowed: 30,
Warning: 10,
Countertext: 'remaining words :'
});
});
</SCRIPT>
DEMO code
Package, package, and download