(function($){
$.fn.artTxtCount = function(content,tipWrap, minNum, maxNum){
var count = function(){
len = $(this).val().length;
if(len < minNum) {
tipWrap.html('已输入<font color="#000">' + len + '</font>个字符。');
}
else if(len < maxNum && len >= minNum) {
tipWrap.html('还可以输入<font color="#000">' + (maxNum-len) + '</font>个字符。');
}
else if(len >= maxNum){
content.attr("value",$(this).val().substring(0,maxNum));
tipWrap.html('<font color="red">还可以输入0个字符!</font>');
}
};
$(this).bind('keyup change', count);
return this;
};
})(jQuery);
$(document).ready(function(){
$('#contactContent').artTxtCount($('#contactContent'), $('#contactTips'), 10, 1000);//参数:textarea的id,span的id, 最少字符数, 最大字符数
});