text: !function($,windows,document,undefined){var limitObj=function(ele,opts){this.$ele=ele;var me=this;this.defaults={type:"number",regularExpression:"",negative:!0,first:8,last:2,includeZero:!0,max:"normal",min:"normal",underline:!0,callback:function(){}},this.options=$.extend({},this.defaults,opts),this.val="",this.init=function(){var opt=this.options;ele.unbind("input propertychange"),ele.bind("input propertychange",function(){var resultVal,originalValue=me.val=ele[0].value;if(""!=originalValue){if("custom"==opt.type){if(!opt.regularExpression)return;resultVal=originalValue.replace(opt.regularExpression,"")}else if("number"===opt.type)resultVal=me.limitNum(ele,originalValue,opt);else if("int"===opt.type){resultVal=originalValue.replace(/[^0-9]/g,""),resultVal=me.removeFirstZero(resultVal);var max=Number(opt.max),min=Number(opt.min);max&&"normal"!==max&&Number(resultVal)>max&&(resultVal=opt.max),min&&"normal"!==min&&Number(resultVal)>min&&(resultVal=min)}else"letters"===opt.type?resultVal=originalValue.replace(/[^a-z A-Z]/g,""):"number_letters"===opt.type&&(resultVal=originalValue.replace(/[^\w]/gi,""),opt.underline||(resultVal=resultVal.replace(/_/g,"")));resultVal.length>opt.first&&(resultVal=resultVal.substring(0,opt.first)),resultVal!==originalValue&&(ele.val(resultVal),me.setCaretPosition(resultVal,ele),opt.callback&&opt.callback(ele,resultVal))}})},this.limitNum=function(node,vals,opt){var testRuler,first=opt.first,last=opt.last,val=vals,resultVal="";testRuler=first&&"normal"!==first&&"normal"!==last?new RegExp("^\\d{0,"+first+"}(?:\\.\\d{0,"+last+"})?$"):last&&"normal"!==last?new RegExp("^\\d*(?:\\.\\d{0,"+last+"})?$"):new RegExp("^\\d*(?:\\.\\d)?$");var negative=val.charAt(0);testRuler.test(val)||(val=val.replace(/[^\d.]/g,"")),resultVal=function(val){var result="";if(-1===val.indexOf(".")){var num=val;num=num.toString(),first&&"normal"!==first&&num.length>first&&"normal"!==first&&(num=num.substring(0,first)),result=num,result=me.removeFirstZero(result)}else{var left=val.split(".")[0],right=val.split(".")[1];""!=left&&left!=undefined&&null!=left||!last||"normal"===last?""!=right&&right!=undefined&&null!=right||!first||"normal"===first?(first&&"normal"!==first&&(left=left.substring(0,first)),last&&"normal"!==last&&(right=right.substring(0,last))):(left=left.substring(0,first),right=""):(left="0",right=right.substring(0,last)),result=left+"."+right}return result}(val);var max=Number(opt.max);return"-"===negative&&opt.negative?resultVal="-"+resultVal:max&&"normal"!==max&&Number(resultVal)>max&&(resultVal=opt.max),resultVal},this.removeFirstZero=function(val){var resultVal=val;return this.options.includeZero&&resultVal.length>=1?""===(resultVal=resultVal.replace(/\b(0+)/gi,""))&&(resultVal="0"):resultVal=resultVal.replace(/\b(0+)/gi,""),resultVal},this.setCaretPosition=function(resultVal,node){var pos,lessThenIE8=function(){var UA=navigator.userAgent;return(UA.indexOf("MSIE")>-1?/\d+/.exec(UA.split(";")[1]):"no ie")<=8};resultVal===this.options.max&&(pos=resultVal.toString().length),lessThenIE8()?$(document).bind("contextmenu",function(){return!1}):pos=function(ctrl){var CaretPos=0;if(document.selection){ctrl.focus();var Sel=document.selection.createRange();Sel.moveStart("character",-ctrl.value.length),CaretPos=Sel.text.length}else(ctrl.selectionStart||"0"==ctrl.selectionStart)&&(CaretPos=ctrl.selectionStart);return CaretPos}(node[0]),node.trigger("focus"),lessThenIE8()||pos||function(ctrl,pos){if(ctrl.setSelectionRange)ctrl.focus(),ctrl.setSelectionRange(pos,pos);else if(ctrl.createTextRange){var range=ctrl.createTextRange();range.collapse(!0),range.moveEnd("character",pos),range.moveStart("character",pos),range.select()}}(node[0],pos)},this.init()};limitObj.prototype={},$.fn.limit=function(options){return this.each(function(){return new limitObj($(this),options)})}}(jQuery,window,document);