Upload your document(s) (Up to 1 attachments)
` ); } } const spinner = '
'; form.getFormElem().closest("body").append(spinner); /** * This module is responsible for handling file input fields on the dom. * There are at anytime 1-3 file input fields. * * When user selects a file then module will add another file input field to the dom, * (provided that the LIMIT has not been reached). Also if user deselects a file * input field the module will delete file input field to the bottom (if it is not * the bottom input field) */ const fileInputListModule = (function ($fileInput, $) { const fileInputList = []; const fileInputContainer = formEle.querySelector('.file-input-container'); let incrementor = 0; let $fileError = null; // Initialize the first file input field already on DOM fileInputList.push($fileInput); $fileInput.change(handleChange); /** * Provides a copy of the fileInputList */ function getFileList() { return fileInputList.slice(0); } function setFileError(fileName,errorMsg) { fileName.closest(".mktoFormRow").find(".mktoError").remove(); fileName.parent().after( `
` + errorMsg + `
` ); fileName[0].classList.add("mktoInvalid"); } function removeFileError(fileName) { $(fileInputContainer).find(".mktoError").remove(); fileName[0]?.classList.remove("mktoInvalid"); } function handleDeleteBtn(e) { const target = e.currentTarget; const $inputEl = $(target.parentNode).closest('.input-upload-wrapper').find('input'); const inputIndex = findIndex($inputEl); if (inputIndex > -1 && LIMIT > 1) { removeInput(inputIndex); } else { // If there's only a single upload field, just remove the delete button target.removeEventListener('click', handleDeleteBtn); target.remove(); $inputEl.removeClass('hideChooseButton'); $inputEl.val(''); } // When the number of input fields reaches the limit and one of them is removed, add // an input field with the Choose File button visible if (fileInputList.every($input => $input.hasClass('hideChooseButton')) || !fileInputList?.length) { addNewInput(false); } // when Upload Required is checked and all input with a file is removed, show the error if (uploadRequired && fileInputList.every($input => !$input.val().length)) { setFileError(fileInputList[fileInputList.length - 1], "This is required") } } function addDeleteBtn(el) { const ariaLabel = "Remove file"; el.parentNode.insertAdjacentHTML('beforeend', `