function saveAndSubmitLogic(submitButtonField,fieldsToExclude,tabulated){ //debugger; if (submitButtonField) { var validationAlert = $(".validation-summary.alert.alert-error.alert-danger.alert-block"); if (validationAlert.is(":visible")) { submitButtonField.prop("checked", false); } } var formId = $(".entity-form"); //debugger; // add an required asterisk to each specified field (css visual only, does not actually enforce) formId.find(".form-control input-text-box, input[type='text'], textarea, select, input[type='checkbox'], .flexbox[id$='ControlView'], input[type='url'], input[type='email'], input[type='radio']").each(function() { var fieldName var fieldLabel //var parsefieldsToExclude = JSON.parse(fieldsToExclude); if (fieldsToExclude) { var fieldsToExcludeArray = fieldsToExclude.split(","); var excludedIds = fieldsToExcludeArray; } var currentId = $(this).attr("id"); if(($(this).hasClass('msos-checkbox')) || ($(this).hasClass('ag-input-field-input')) || ($(this).is('select') && $(this).prop('multiple')) || ($(this).is("[data-date-format]"))){ return; } else if ((currentId !== undefined && $(this).attr('type') === 'checkbox')) { return; } else if ((currentId !== undefined && $(this).hasClass('msos-input') && $(this).attr('id').indexOf('_ledit') !== -1)){ currentId = this.id; fieldName = currentId.replace('_ledit', ''); fieldLabel = $("#"+ fieldName + "_label").html(); } else if ((currentId !== undefined && $(this).hasClass('flexbox') && $(this).attr('id').indexOf('_ControlView') !== -1)) { currentId = this.id; fieldName = currentId.replace('_ControlView', ''); fieldLabel = $("#"+ fieldName + "_label").html(); } else if (currentId !== undefined && $(this).attr('id').indexOf('_name') !== -1) { currentId = this.id; fieldName = currentId.replace('_name', ''); fieldLabel = $("#"+ fieldName + "_label").html(); } else if ($(this).is(":radio")){ fieldName = $(this)[0].parentElement.id; fieldLabel = $('#'+$(this)[0].parentElement.id+'_label').html(); } else{ fieldName = this.id; fieldLabel = $("#"+ this.id + "_label").html(); } if (fieldsToExclude && excludedIds.includes(fieldName)) { return; } if (!fieldLabel) { return; // prevents errors } addValidatorNew(fieldName, fieldLabel, function(val) { return requireFieldValidatorIfNotHidden(val, submitButtonField); }, tabulated); }); function requireFieldValidatorIfNotHidden(val,submitButtonField) { var control = val.ownerDocument.getElementById(val.controltovalidate); if (submitButtonField) { var submitButton1Checked = submitButtonField.is(':checked'); if (submitButton1Checked == false) return true; } if(($(control).closest("fieldset").css("display") == 'none') || ($(control).closest("td").css("display") == 'none')) return true; //Use Existing RequiredField Validator return val.ownerDocument.defaultView.RequiredFieldValidatorEvaluateIsValid(val); } } function addSubmitButton(buttonText, submitButtonField){ // submit button logic //var submitButtonText = "Submit Application"; //$($(".row.form-custom-actions .col-md-6.clearfix")[1]).append("
"); var submitButton = document.querySelector("#NewSubmitButton"); if (submitButton) { submitButton.addEventListener("click", function(e){ //debugger; if ($("#NewSubmitButton").is('[disabled]')) { e.preventDefault(); return; } var saveButton = document.querySelector(".submit-btn"); //$("#cftb_applicationsubmitbutton_1").prop("checked", true); submitButtonField.prop("checked", true); saveButton.click(); var validationAlert = $(".validation-summary.alert.alert-error.alert-danger.alert-block"); if (validationAlert.is(":visible")) { //submitButtonField.prop("checked", false); // sets submit button back to no - have to replace the 1 with the 0 because 1 is yes and 0 is no var submitButtonNoId = submitButtonField.attr('id').replace('_1', '_0'); var submitButtonNo = $("#" + submitButtonNoId); submitButtonNo.prop("checked", true); } }); } } var tabs = []; var submitButtonField; // Call this after RenderTabsV5() function initializeTabs() { tabs = []; $(".nav-link[data-bs-toggle='tab']:visible").each(function () { var tabId = $(this).attr("id").replace("-tab", ""); tabs.push(tabId); }); // Add previous/next buttons if ($("#next-tab").length === 0) { var actionsContainer = $($(".row.form-custom-actions .col-md-6.clearfix")[1]); // Create a single container for all action buttons var buttonGroup = $(` `); // Only add submit button if submitButton is not null or undefined if (submitButtonField) { buttonGroup.append(`Submit`); } actionsContainer.append(buttonGroup); $("#next-tab").click(() => moveTab("next")); $("#previous-tab").click(() => moveTab("previous")); } hideShowNavigation(getActiveTabId()); // on change of active tab $(document).on("shown.bs.tab", ".nav-link[data-bs-toggle='tab']", function (e) { var activeTabId = getActiveTabId(); hideShowNavigation(activeTabId); }); } function getActiveTabId() { return $("#tabNav .nav-link.active").attr("id").replace("-tab", ""); } function moveTab(direction) { var currentTabId = getActiveTabId(); var index = tabs.indexOf(currentTabId); if (index === -1) { index = 0; } if (direction === "next" && index < tabs.length - 1) { index++; } else if (direction === "previous" && index > 0) { index--; } var newTabId = tabs[index]; var tabEl = document.getElementById(newTabId + "-tab"); var tab = new bootstrap.Tab(tabEl); tab.show(); // Update URL with ?tab= var url = new URL(window.location); url.searchParams.set('tab', newTabId); window.history.pushState({}, '', url); hideShowNavigation(newTabId); } function hideShowNavigation(activeTabId) { var firstTab = tabs[0]; var lastTab = tabs[tabs.length - 1]; if (activeTabId === firstTab) { $("#previous-tab").hide(); $("#next-tab").show(); if (submitButtonField) { $("#NewSubmitButton").hide(); } } else if (activeTabId === lastTab) { $("#next-tab").hide(); $("#previous-tab").show(); if (submitButtonField) { $("#NewSubmitButton").show(); } } else { $("#previous-tab").show(); $("#next-tab").show(); if (submitButtonField) { $("#NewSubmitButton").hide(); } } }