(function(){JUI.Class("Validate",{OPTS:$.extend({rule:{},msgId:"",errorMsg:"",successMsg:"",validateHandler:null},JUIConfig.Validate),init:function(a){this.opts=$.extend({},this.OPTS,a);this.setMsgId(this.opts.msgId)},setMsgId:function(a){this.opts.msgId=a;this.$msgDiv=$("#"+this.opts.msgId)},showErrorMsg:function(a){if(this.opts.errorClass){this.$msgDiv.removeClass().addClass(this.opts.errorClass)}this.$msgDiv.html(a||this.opts.errorMsg)},showSuccessMsg:function(a){if(this.opts.successClass){this.$msgDiv.removeClass().addClass(this.opts.successClass)}this.$msgDiv.html(a||this.opts.successMsg)},validate:function(f){if(typeof this.opts.validateHandler==="function"){var b=this.opts.validateHandler(f);if(!b){this.showErrorMsg()}return b}var e=this.opts.rule;for(var d in e){var a=this.getValueLength(f);if(a===0){if(this.opts.rule.notNull){this.showErrorMsg();return false}return true}if(!this.validateLength(f)){return false}var c=e[d];if(c&&!this.validateItem(f,d)){return false}}this.showSuccessMsg();return true},validateLength:function(d){var a=this.getValueLength(d);var c=this.opts.rule.minLength||-1;var b=this.opts.rule.maxLength||-1;if(c!==-1){if(a<c){this.showErrorMsg();return false}}if(b!==-1){if(a>b){this.showErrorMsg();return false}}return true},validateItem:function(d,a){var c=JUI.ValidateStore;var b=c[a];if($.isFunction(b)){if(!b(d)){this.showErrorMsg();return false}}return true},getValueLength:function(a){if(typeof a==="undefined"){return 0}if($.isArray(a)){return a.length}return(a+"").replace(/[^\x00-\xff]/g,"**").length}});JUI.ValidateStore=(function(){var b=/^[1-9]\d*$/,h=/^(0|([1-9]\d*))$/,a=/^(((0|([1-9]\d*))[\.]?[0-9]+)|[1-9])$/,i=/^-?[0-9]{1,4}([.]{1}[0-9]{1,})?$/,g=/^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/,e=/^[0-9]{1,4}([.]{1}[0-9]{1,})?$/,f=/^\s*[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+\s*$/,d=/^\s*(\+86)*0*1(3|5|8)\d{9}\s*$/,c=/\(?0\d{2,3}[)-]?\d{7,8}/;return{positiveInt:function(j){return b.test(j)},naturalNum:function(j){return h.test(j)},positiveNum:function(j){return a.test(j)},floatNum:function(j){return i.test(j)},positiveFloatNum:function(j){return g.test(j)},notNegativeFloatNum:function(j){if(j===0){return true}return e.test(j)},email:function(j){return f.test(j)},mobile:function(j){return d.test(j)},tel:function(j){return c.test(j)}}})()})();