(function(a){a.formValidate={type:{email:/^([a-z\d]+)([\._a-z\d-]+)*@([a-z\d])([_a-z\d-])+(\.[_a-z\d-]+)*\.([a-z]{2,4})$/i,domain:/^(https?:\/\/)([\w-]+\.)+[a-z]{2,4}\b/i,mobile:/^1(3|5|8|4)\d{9}$/,chinamobile:/^1(3[4-9]|4[7]|5[0-2|7-9]|8[7-9])[0-9]{8}$/,numeric:/^[-\+]?\d+(\.\d+)?$/,integer:/^[-\+]?\d+$/,chinese:/^([\u4e00-\u9fa5]+)$/,tel:/^\d{3,4}-?\d{7,8}$/,idcard:/^\d{14}(\d|\d{4}|(\d{3}[xy]))$/i,date:/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])$/},textReplace:function(b){return b.replace(/^[ 　]+/,"").replace(/[ 　]+$/,"").replace(/^\s+/,"").replace(/\s+$/,"").replace(/\n\n\n+/g,"\n\n\n")},textLength:function(d,b){if(b){var c=d.replace(/[^\x00-\xff]/g,"aa");return Math.ceil(c.length/2)}return d.length},getNumber:function(g,c,d){var f=this.textReplace(g),b=this.textLength(f,d),e=c-b;return e},check:function(){if(arguments.length==1){var b=arguments[0];if(typeof b=="string"){var f=b}else{var i=b}}else{var f=arguments[0];var i=arguments[1]}var h="formvalidatecheck",e=f?a("."+f):a(".formValidateSubmit"),j=e.data(h),c=true,g=true;if(!j){return true}if(i){a.each(j,function(k,d){if(d.input==i){g=d.isOK;return false}});return g}else{a.each(j,function(k,d){if(!d.isOK){c=false;return false}});return c}}};a.fn.extend({formValidate:function(c){var b={button:"formValidateSubmit",blankSubmit:"blanksubmit",rel:"rel",reg:"reg",regTrue:"regtrue",focus:"focuscolor",blankValue:"blankvalue",blankClass:"blankclass"};var d="formvalidatecheck",e=a.formValidate.type;if(c){a.each(c,function(f,g){b[f]=g})}a(this).each(function(){var h=a(this),l=h[0].nodeName=="INPUT",k=h[0].nodeName=="SELECT",f=a("."+b.button),n=h.attr(b.focus),j=n==undefined||n=="true";i();h.bind("blur.formValidateBlur",function(){if(!k&&j){h.removeClass("focus")}var w=h.attr(b.rel)?a("#"+h.attr(b.rel)):h,y=a.formValidate.textReplace(w.val()),z=w.attr(b.reg),x=h.attr(b.blankSubmit),q=h.attr(b.blankValue),A=x==undefined||x=="false",t,u,p,s,o;if(A&&(y==""||h.val()==q)){i();m(false);return}if(!A&&(y==""||h.val()==q)){i();g(true);return}if(!k){w.val(y)}t=w.val().replace(/\n/g,",");if(!z){o=false}else{if(z.slice(0,4)=="fun:"){o=!window[z.slice(4)].call(h[0],t)}else{u=h.attr(b.regTrue)!=="false";p=z in e?e[z]:new RegExp(z);s=p.test(t);o=u?!s:s}}if(o){m(false)}else{m(true)}}).focus(function(){if(!k){h.click()}if(!k&&j){h.addClass("focus")}i(false)});f.click(function(){h.triggerHandler("blur.formValidateBlur")});function m(o){if(arguments.length==0){return}g(o)}function i(){if(k){return}var p=h.attr(b.blankValue);var o=h.attr(b.blankClass);if(p==undefined||p==""){return}if(!arguments.length){var q=h.val();if(q==""||q==p){h.val(p).addClass(o)}else{h.removeClass(o)}}else{var q=h.val();if(q==""||q==p){h.val("").removeClass(o)}}}function g(o){var q=f.data(d),p=false;if(!q){f.data(d,[{input:h[0],isOK:o}]);return}a.each(q,function(s,r){if(r.input==h[0]){r.isOK=o;p=true;return false}});if(!p){q.push({input:h[0],isOK:o})}f.data(d,q)}});return this}})})(jQuery);
