Server IP : 150.95.80.236 / Your IP : 3.137.164.69 Web Server : Apache System : Linux host-150-95-80-236 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : social-telecare ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/pcu.in.th/uat.pcu.in.th/assets/plugins/formvalidation/dist/es6/plugins/ |
Upload File : |
import t from"../core/Plugin";export default class e extends t{constructor(t){super(t);this.fieldValidHandler=this.onFieldValid.bind(this);this.fieldInvalidHandler=this.onFieldInvalid.bind(this)}install(){const t=this.core.getFields();this.startDateFieldOptions=t[this.opts.startDate.field];this.endDateFieldOptions=t[this.opts.endDate.field];const e=this.core.getFormElement();this.core.on("core.field.valid",this.fieldValidHandler).on("core.field.invalid",this.fieldInvalidHandler).addField(this.opts.startDate.field,{validators:{date:{format:this.opts.format,max:()=>{const t=e.querySelector(`[name="${this.opts.endDate.field}"]`);return t.value},message:this.opts.startDate.message}}}).addField(this.opts.endDate.field,{validators:{date:{format:this.opts.format,message:this.opts.endDate.message,min:()=>{const t=e.querySelector(`[name="${this.opts.startDate.field}"]`);return t.value}}}})}uninstall(){this.core.removeField(this.opts.startDate.field);if(this.startDateFieldOptions){this.core.addField(this.opts.startDate.field,this.startDateFieldOptions)}this.core.removeField(this.opts.endDate.field);if(this.endDateFieldOptions){this.core.addField(this.opts.endDate.field,this.endDateFieldOptions)}this.core.off("core.field.valid",this.fieldValidHandler).off("core.field.invalid",this.fieldInvalidHandler)}onFieldInvalid(t){switch(t){case this.opts.startDate.field:this.startDateValid=false;break;case this.opts.endDate.field:this.endDateValid=false;break;default:break}}onFieldValid(t){switch(t){case this.opts.startDate.field:this.startDateValid=true;if(this.endDateValid===false){this.core.revalidateField(this.opts.endDate.field)}break;case this.opts.endDate.field:this.endDateValid=true;if(this.startDateValid===false){this.core.revalidateField(this.opts.startDate.field)}break;default:break}}}