(function(n){n.validator.addMethod("atleastnwords",function(n,t,i){if(n.length===0)return!0;n=n.trim();const f=n.split(/\s+/);let r=0,u=!1;for(const n of f)if(/[a-zA-Z]/.test(n)&&(r++,n.length>=3&&(u=!0),r>=i.number&&u))return!0;return r>=i.number&&u});n.validator.unobtrusive.adapters.add("atleastnwords",["number"],function(n){n.rules.atleastnwords={number:n.params.number};temp=n;n.messages.atleastnwords=n.message});n.validator.addMethod("atleastonerequired",function(value,element,params){var result=!1,propsArray;try{propsArray=eval(params.props);n.each(propsArray,function(t,i){if(n("#"+i).val())return result=!0,!1})}catch(err){console.log(err);result=!0}return result});n.validator.unobtrusive.adapters.add("atleastonerequired",["props"],function(n){n.rules.atleastonerequired={props:n.params.props};n.messages.atleastonerequired=n.message});n.validator.addMethod("atleastonerequiredif",function(t,i,r){let u=!1;try{let propsArray=eval(r.props);n.each(propsArray,function(t,i){if(n("#"+i).val())return u=!0,!1})}catch(f){console.log(f);u=!0}if(u===!0)return!0;let e=n(i).attr("validationdata");if(e==="radio"){let f=r.desiredvalue;f=(f==null?"":f).toString();let e=n("input[id$='"+r.dependentproperty+"']").attr("type"),u={};if(e==="checkbox"||e==="radio"){let t=n("input[id$='"+r.dependentproperty+"']:checked");u=t.val()}else u=n("#"+r.dependentproperty).val();if(u=(u==null?"":u).toString(),f.trim().toLowerCase()===u.trim().toLocaleLowerCase())return n.validator.methods.required.call(this,t,i,r)}else{if(n(i).val()!=="")return!0;let t=n("#"+n(i).attr("id").substring(0,n(i).attr("id").lastIndexOf("_")+1)+r.other),u="false";return t.attr("type")&&t.attr("type").toUpperCase()==="CHECKBOX"?u=t.prop("checked")?"true":"false":t.val()&&(u=t.val().toLowerCase()),r.comp==="isequalto"?u!==r.value:u===r.value}});n.validator.unobtrusive.adapters.add("atleastonerequiredif",["other","comp","value","uselabel","props"],function(t){if(t.rules.atleastonerequiredif={other:t.params.other,comp:t.params.comp,value:t.params.value,props:t.params.props},t.messages.atleastonerequiredif=t.message,t.params.uselabel==="true"){let i=n("label[for='"+t.element.id+"']");i&&(t.messages.requiredif=i.text())}});n.validator.addMethod("integerrange",function(n,t,i){let r=!1;try{if(i.req&&n==="")return!0;let t=Number(n.replace(",","."));r=t>=i.min&&t<=i.max}catch(u){console.log("integerrange error : "+u);r=!1}return r});n.validator.unobtrusive.adapters.add("integerrange",["min","max","req"],function(n){n.rules.integerrange={min:n.params.min,max:n.params.max,req:n.params.req};n.messages.integerrange=n.message});n.validator.addMethod("regexif",function(t,i,r){if(t.match(r.regex)&&t==t.match(r.regex)[0]||!n(i).val())return!0;var u=n("#"+n(i).attr("id").substring(0,n(i).attr("id").lastIndexOf("_")+1)+r.other),f="false";return u.attr("type")&&u.attr("type").toUpperCase()=="CHECKBOX"?f=u.prop("checked")?"true":"false":u.val()&&(f=u.val().toLowerCase()),r.comp=="isequalto"?f!=r.value:f==r.value});n.validator.unobtrusive.adapters.add("regexif",["regex","other","comp","value","uselabel"],function(t){if(t.rules.regexif={regex:t.params.regex,other:t.params.other,comp:t.params.comp,value:t.params.value},t.messages.regexif=t.message,t.params.uselabel=="true"){var i=n("label[for='"+t.element.id+"']");i&&(t.messages.regexif=i.text())}});n.validator.addMethod("requiredif",function(t,i,r){var c=n(i).attr("validationdata"),e,s,u,h,f,o;if(c==="radio"){if(e=r.desiredvalue,e=(e==null?"":e).toString(),s=n("input[id$='"+r.dependentproperty+"']").attr("type"),u={},s=="checkbox"||s=="radio"?(h=n("input[id$='"+r.dependentproperty+"']:checked"),u=h.val()):u=n("#"+r.dependentproperty).val(),u=(u==null?"":u).toString(),e.trim().toLowerCase()===u.trim().toLocaleLowerCase())return n.validator.methods.required.call(this,t,i,r)}else return n(i).val()!=""?!0:(f=n("#"+n(i).attr("id").substring(0,n(i).attr("id").lastIndexOf("_")+1)+r.other),o="false",f.attr("type")&&f.attr("type").toUpperCase()=="CHECKBOX"?o=f.prop("checked")?"true":"false":f.val()&&(o=f.val().toLowerCase()),r.comp=="isequalto"?o!=r.value:o==r.value)});n.validator.unobtrusive.adapters.add("requiredif",["other","comp","value","uselabel"],function(t){if(t.rules.requiredif={other:t.params.other,comp:t.params.comp,value:t.params.value},t.messages.requiredif=t.message,t.params.uselabel=="true"){var i=n("label[for='"+t.element.id+"']");i&&(t.messages.requiredif=i.text())}});var t=n.validator.methods.range;n.validator.methods.range=function(n,i,r){return i.type==="checkbox"?i.checked:t.call(this,n,i,r)};n.validator.addMethod("enforcetrue",function(n,t){return t.checked});n.validator.unobtrusive.adapters.addBool("enforcetrue")})(jQuery)