yiisoft/yii — pull request #3416 by gsalgadotoledo (2014-06-21 23:26:42+00:00)
Title: Validate length of textarea converting line breaks into a character

when I try to validate the length of a field sent from a textarea with line breaks not well accepted

Right now it work perfect! =)
![captura de pantalla 2014-06-21 a la s 18 20 29](https://cloud.githubusercontent.com/assets/1288502/3350239/dc95f2c6-f99a-11e3-9a02-9457811e9eb4.png)

![captura de pantalla 2014-06-21 a la s 18 21 20](https://cloud.githubusercontent.com/assets/1288502/3350241/fa4d86da-f99a-11e3-9ecf-9f7de7768398.png)

Please review this change.

In my JS I have this:

```javascript
/*
*	Character Count Plugin - jQuery plugin
*	Dynamic character count for text areas and input fields
*	written by Alen Grakalic
*	http://cssglobe.com/post/7161/jquery-plugin-simplest-twitterlike-dynamic-character-count-for-textareas
*
*	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
*	Dual licensed under the MIT (MIT-LICENSE.txt)
*	and GPL (GPL-LICENSE.txt) licenses.
*
*	Built for jQuery library
*	http://jquery.com
*
*/

(function($) {

$.fn.charCount = function(options){

// default configuration properties
var defaults = {
allowed: 140,
warning: 25,
css: 'counter',
counterElement: 'span',
cssWarning: 'warning',
cssExceeded: 'exceeded',
counterText: ''
};

var options = $.extend(defaults, options);

function calculate(obj){
var count = $(obj).val().length;
var available = options.allowed - count;
if(available <= options.warning && available >= 0){
$(obj).next().addClass(options.cssWarning);
} else {
$(obj).next().removeClass(options.cssWarning);
}
if(available < 0){
$(obj).next().addClass(options.cssExceeded);
} else {
$(obj).next().removeClass(options.cssExceeded);
}
$(obj).next().html(available+options.counterText);
};

this.each(function() {
$(this).after('<'+ options.counterElement +' class="' + options.css + '">'+ options.counterText +'');
calculate(this);
$(this).keyup(function(){calculate(this)});
$(this).change(function(){calculate(this)});
});

};

})(jQuery);

```