| 1 |
var validateForm=function(){"use strict";let e,t,i={},n=[];const r=t=>window?.bf_globals?.[e].inits?.[t],l=e=>{const n=e.replace(/\[\d*\]/g,"");if(i[n])return i[n];const r=Object.entries(t);for(let e=0;e<r.length;e+=1){const[t,l]=r[e];if(l?.fieldName===n)return i[n]=t,t}return""},o=()=>{const n=new FormData(bfSelect(`#form-${e}`)),r={},o=Array.from(n.entries());return i={},o.forEach((([e,i])=>{const n=l(e),o=e.replace("[]","");n in t&&(r[o]?(Array.isArray(r[o])||(r[o]=[r[o]]),r[o].push(i)):r[o]=i)})),r},d=(t,i,r,l="")=>{const o=bfSelect(`#form-${e} ${l} .${i}-err-wrp`),d=bfSelect(`.${i}-err-txt`,o),a=bfSelect(`.${i}-err-msg`,o);let s=!1;try{s="grid"===getComputedStyle(o).display,s&&(o.style.removeProperty("opacity"),o.style.removeProperty("height"),a.style.removeProperty("display"))}catch(e){s=!1}d&&"err"in(r||{})&&(t&&r?.err?.[t]?.show?(d.innerHTML=r.err[t].custom?r.err[t].msg:r.err[t].dflt,s?setStyleProperty(o,"grid-template-rows","1fr"):setTimeout((()=>{a.style.removeProperty("display"),setStyleProperty(o,"height",`${d.offsetHeight}px`),setStyleProperty(o,"opacity",1)}),100),n.push(i)):(d.innerHTML="",s?setStyleProperty(o,"grid-template-rows","0fr"):(setStyleProperty(o,"height",0),setStyleProperty(o,"opacity",0),setStyleProperty(a,"display","none"))))};return function({form:i,input:a},{step:s,otherOptions:f}={}){i?e=i:a?.form?.id&&([,e]=a.form.id.split("form-"));const c=window?.bf_globals?.[e];if(void 0===c)return!1;let p={};n=[];const u=c.configs.bf_separator;if(s){let e=c.layout[s-1];if(!e)return!1;e=e?.layout||e;const i=e.lg.map((e=>e.i)),n=c.nestedLayout||{};Object.entries(n).forEach((([e,t])=>{if(i.includes(e)){const e=t.lg.map((e=>e.i));i.push(...e)}})),t=i.reduce(((e,t)=>({...e,[t]:c.fields[t]})),{})}else t=c.fields;const{modifiedFields:y}=c;if(y&&Object.assign(t,y),i)p=o();else if(a){if(!c.validateFocusLost&&!f?.validateOnInput)return!0;const e=l(a.name);p=o(),t={[e]:t[e]}}let m=!0;const h=Object.entries(t);let{length:g}=h;for(;g--;){const[t,i]=h[g];let n=[""];if("undefined"!=typeof checkRepeatedField){const e=checkRepeatedField(t,c);n=getRepeatedIndexes(e,c,a)}for(let l=0;l<n.length;l+=1){const o=n[l],a=o?`${i.fieldName}[${o}]`:i.fieldName,s=o?`.rpt-index-${o}`:"",f=i.typ,c="string"==typeof p[a]?p[a].trim():p[a];if(bfSelect(`#form-${e} ${s} .${t}.fld-hide`)){d("",t,i,s);continue}let y="";"check"===f&&(y="undefined"!=typeof checkFldValidation?checkFldValidation(c,i):""),"check"!==f&&"radio"!==f||y||"undefined"==typeof customOptionValidation||(y=customOptionValidation(e,t,i)),c||y||(y="undefined"!=typeof requiredFldValidation?requiredFldValidation(i):null),d(y,t,i,s),y?m=!1:c&&("number"===f&&"undefined"!=typeof nmbrFldValidation?y=nmbrFldValidation(c,i):"email"===f&&"undefined"!=typeof emailFldValidation?y=emailFldValidation(c,i):"url"===f&&"undefined"!=typeof urlFldValidation?y=urlFldValidation(c,i):["decision-box","gdpr"].includes(f)&&"undefined"!=typeof dcsnbxFldValidation?y=dcsnbxFldValidation(c,i):["check","select","image-select"].includes(f)&&"undefined"!=typeof checkMinMaxOptions?y=checkMinMaxOptions(c,i,u):"range"===f&&"undefined"!=typeof checkMinMaxValue?y=checkMinMaxValue(c,i):"file-up"===f&&"undefined"!=typeof fileupFldValidation?y=fileupFldValidation(c,i):"advanced-file-up"===f&&"undefined"!=typeof advanceFileUpFldValidation?y=advanceFileUpFldValidation(r(t),i):"phone-number"===f&&"undefined"!=typeof phoneNumberFldValidation&&(y=phoneNumberFldValidation(r(t),i)),i?.valid?.regexr&&!y&&(y="undefined"!=typeof regexPatternValidation?regexPatternValidation(c,i):null),d(y,t,i,s),y&&(m=!1))}}return moveToFirstErrFld(c,n),m}}(); |