Monday 5 August 2013

Line/Word/Character Count in Textbox Control using Javascript funtion

JavaScript Funtion:

function LineCount(value) {
       
                    var text;
                    var lines_totals1;
                    var len;
                    var line_count;
                    var lines_totals2;
                    var diff_fli;
                    var totalCost;
                    var ExtraLine;

                    text = value;
                    lines_totals1 = Math.ceil(value.length / 23);
                    len = wordwrap(text, 23, "\n", true);
                    line_count = len.split("\n");
                    lines_totals2 = line_count.length;
                    diff_fli = lines_totals2 - lines_totals1;

                    if (diff_fli > 1) {
                        lines_totals = Math.ceil((lines_totals2 + lines_totals1) / 2);
                    }
                    else {
                        lines_totals = lines_totals2;
                    }
            }
         
        function wordcount(value) {
         
                var totalCost;
                var ExtraWord;

                var andchr = value.split(" & ").length - 1;
                var char_count = value.length;
                var fullStr = value + " ";

                //word count for regional language
                v = value.split(' ');
                var word_count = v.length;
                var cheArr = Array('@', '.', '"', "'", '_', '-', '+', '=', ';', '&', '*', '\(', '\)', '{', '}', '[', '}', '|', '\\', '\,', '/');
                for (i = 0; i <= cheArr.length; i++) {
                    word_count = word_count + value.split(cheArr[i]).length - 1;
                }

             
        }


        function charcount(value) {

         
                var totalCost;
                var ExtraWord;
                value = value.replace(/^\s+|\s+$/g, "");
                var word_count = value.length;

             

        }

No comments:

Post a Comment