[JS Open Source Component Development]js text box count component

Source: Internet
Author: User

JS text Box Count component

First on:

The style can be self-adjusting, its function provides a real-time text box count, and make corresponding actions, such as now beyond, click on the button below, the text box will blink twice, block the submission. A specific example can be clicked on demo:http://www.lovewebgames.com/jsmodule/word-count.html, whose source file is hosted on GitHub: https://github.com/ Tianxiangbing/word-count

Examples of Use methods:
<div class= "Txt-count-container" > <div class= "Counter" ><em>30</em></div> < TextArea name= "txt" id= "txt" cols= "ten" rows= "class=" "txt" > Million color city is a business platform, all the million-color city of the network to join, register a belong to their own online mall. Promote their own shopping malls, the sale of merchandise to create revenue. Each network trader has a separate domain name that belongs to itself. Million Color city is the only full implementation of the "real name" of the online shopping mall, each network business, with their true names, photos and reputation, as the guarantee of good faith management. </textarea></div> <p><input type= "button" value= "click Submit" class= "click" ></p> <script t Ype= "Text/javascript" src= ". /src/zepto.js "></script> <script type=" Text/javascript "src=".                /src/word-count.js "></script> <script> $ (function () {$ (". Click "). Click (function () {            if (!$ ('. txt '). Data (' overflow ') {alert (' OK ')}}); $ ('. txt ').                WordCount ({max:200, isoverflowcut:false, Overclass: "Over-number", num:$ (". Counter em"), Withbutton: ". Click", MinHeight: Overflowcallback:function () {//this.textbox.addclass (' over-number ');                $ (". Counter em"). AddClass (' Over-number ');                    }, Changecallback:function (num) {//var n = this.max-num;                $ (". Counter em"). HTML (n);                    }, Passclallback:function () {//this.textbox.removeclass (' over-number ');                $ (". Counter em"). Removeclass (' Over-number ');        }, isbyte:true//bytes});    }); </script>

  

Or:
var WC = new WordCount (), WC. Init ({        trigger:$ ('. txt '),        max:200,        isoverflowcut:false,        overclass: " Over-number ",        num:$ (". Counter em "),        Withbutton:". Click ",        minheight:100,        overflowcallback: function () {            //this.textbox.addclass (' Over-number ');            $ (". Counter em"). AddClass (' Over-number ');        },        changecallback:function (num) {            //var n = this.max-num ;            $ (". Counter em"). HTML (n);        },        passclallback:function () {            //this.textbox.removeclass (' Over-number ');            $ (". Counter em"). Removeclass (' Over-number ');        },        isbyte:true//bytes    });

  

Properties and Methods Trigger:string | | Object
Triggered text box
Max:number
The maximum length, if not passed, will fetch the text box maxlength
Isoverflowcut:boollen
Whether to automatically intercept text
Overclass:string
Styles that are out of text, are added on Num and textbox at the same time
Num:element
Show the node of the count
Minheight:number
The minimum height of the text box, as this is done with adaptive height control. If you do not write, you will not be self-adaptive.
Withbutton:element
Associate button
Isbyte:boollen
Whether to calculate by number of bytes, true: A Chinese character is 2 unit length, false when the Chinese character is not distinguished from English
Method callback: Overflowcallback:function (N,textbox,max)
Callback when out of bounds, this points to the current object,n为长度,textbox是文本框结点对象,max为最大长度
Changecallback:function (N,textbox,max)
Callback with length change, n is length, TextBox is a text Box node object, max is maximum length
Passclallback:function (N,textbox,max)
callback at length, n is length, TextBox is a text Box node object, max is maximum length

  

[JS Open Source Component Development]js text box count component

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.