/* ** unobtrusive validation support library for jquery and jquery validate ** copyright (c) microsoft corporation. all rights reserved. */ !function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastindexof(".")+1)}function i(a,e){return 0===a.indexof("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parsejson(i)!==!1:null;r.removeclass("field-validation-valid").addclass("field-validation-error"),e.data("unobtrusivecontainer",r),o?(r.empty(),e.removeclass("input-validation-error").appendto(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");r&&r.length&&n.errorlist.length&&(r.empty(),t.addclass("validation-summary-errors").removeclass("validation-summary-valid"),a.each(n.errorlist,function(){a("
").html(this.message).appendto(r)}))}function s(e){var n=e.data("unobtrusivecontainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parsejson(t):null;n.addclass("field-validation-valid").removeclass("field-validation-error"),e.removedata("unobtrusivecontainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetform()}finally{n.removedata(t)}n.find(".validation-summary-errors").addclass("validation-summary-valid").removeclass("validation-summary-errors"),n.find(".field-validation-error").addclass("field-validation-valid").removeclass("field-validation-error").removedata("unobtrusivecontainer").find(">*").removedata("unobtrusivecontainer")}}function m(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=p.unobtrusive.options||{},m=function(n,t){var r=i[n];r&&a.isfunction(r)&&r.apply(e,t)};return t||(t={options:{errorclass:i.errorclass||"input-validation-error",errorelement:i.errorelement||"span",errorplacement:function(){o.apply(e,arguments),m("errorplacement",arguments)},invalidhandler:function(){d.apply(e,arguments),m("invalidhandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),m("success",arguments)}},attachvalidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)},validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var u,p=a.validator,v="unobtrusivevalidation";p.unobtrusive={adapters:[],parseelement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=m(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachvalidation())},parse:function(e){var n=a(e),t=n.parents().addback().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){p.unobtrusive.parseelement(this,!0)}),t.each(function(){var a=m(this);a&&a.attachvalidation()})}},u=p.unobtrusive.adapters,u.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},u.addbool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},u.addminmax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},u.addsingleval=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},p.addmethod("__dummy__",function(a,e,n){return!0}),p.addmethod("regex",function(a,e,n){var t;return this.optional(e)?!0:(t=new regexp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),p.addmethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\w/g),t=t&&t.length>=n),t}),p.methods.extension?(u.addsingleval("accept","mimtype"),u.addsingleval("extension","extension")):u.addsingleval("extension","extension","accept"),u.addsingleval("regex","pattern"),u.addbool("creditcard").addbool("date").addbool("digits").addbool("email").addbool("number").addbool("url"),u.addminmax("length","minlength","maxlength","rangelength").addminmax("range","min","max","range"),u.addminmax("minlength","minlength").addminmax("maxlength","minlength","maxlength"),u.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalto",l)}),u.add("required",function(a){("input"!==a.element.tagname.touppercase()||"checkbox"!==a.element.type.touppercase())&&e(a,"required",!0)}),u.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"get",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),u.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),a(function(){p.unobtrusive.parse(document)})}(jquery);