/*!
 * 输入限制插件
 * www.JSPGen.com
 * @revise 1.0
 */
;(function($){$.fn.extend({inputLimit:function(options){var settings={obj:"textarea",limitObj:"",maxcss:"limit",maxnum:400};$.extend(settings,options);return this.each(function(){var $this=$(this).find(settings.obj);var maxnum=parseInt(settings.maxnum/2);var limitObj=$(this).find(settings.limitObj);$(limitObj).find("em").text(maxnum);if($this.val()!=""){var len=$this.val().replace(/[^\x00-\xff]/g,"**").length;var num=maxnum-parseInt(len/2);$(limitObj).html("还能输入 <em>"+num+"</em> 字");}
$this.focus(function(){$(this).keyup(function(){var end=$(this).val().replace(/[^\x00-\xff]/g,"**").length;var num=maxnum-parseInt(end/2);$(limitObj).html("还能输入 <em>"+num+"</em> 字");if(end>settings.maxnum){$(limitObj).html("已经超出 <em>"+(-num)+"</em> 字");$(limitObj).addClass(settings.maxcss);}else{$(limitObj).removeClass(settings.maxcss);}});});});}});})(jQuery);