���� ������������������������������������ // Step Form Script var currentStep = 1; var totalSteps = 3; var updateProgressBar; function setOtherStateValues(selectElement){ var selectedOption = selectElement.options[selectElement.selectedIndex]; console.log(selectElement.value); var rateGroup = selectedOption.getAttribute('data-rate-group'); var stateAbbreviations = selectedOption.getAttribute('data-state-abbreviations'); var templateIds = selectedOption.getAttribute('data-template-id'); $('#rateGroup').val(rateGroup); $('#stateAbbreviations').val(stateAbbreviations); $('#template_ids').val(templateIds); if(selectElement.value=="Pennsylvania" && $('input[name="ProsperityCoverage"]:checked').val()=="yes"){ $('.ProsperityCoverage').show(); }else{ $('.ProsperityCoverage').hide(); } } function displayStep(stepNumber) { // if (stepNumber >= 1 && stepNumber <= 17) { if (stepNumber >= 1 && stepNumber <= totalSteps) { // $(".step-" + currentStep).hide(); // $(".step-" + stepNumber).show(); setTimeout(function() { $(".step").removeClass("animate__animated animate__fadeOutLeft").hide(); $(".step-" + currentStep).show().addClass("animate__animated animate__fadeInRight"); updateProgressBar(); }, 500); currentStep = stepNumber; updateProgressBar(); } } function showHideMailAddress(){ var mailingAddressValue = $('input[name="mailing_address"]:checked').val(); if(mailingAddressValue === "no"){ $('.mail-address-fields').hide(); $('#MailingStreetAddress').val($('#LegalStreetAddress').val()); $('#MailingCity').val($('#LegalCity').val()); $('#MailingState').val($('#LegalState').val()); $('#MailingZip').val($('#LegalZip').val()); toggleRequiredFields($('.mail-address-fields'), false); } else { $('.mail-address-fields').show(); $('#MailingStreetAddress').val(""); $('#MailingCity').val(""); $('#MailingState').val(""); $('#MailingZip').val(""); toggleRequiredFields($('.mail-address-fields'), true); } } $(document).ready(function() { $('#multi-step-form').find('.step').slice(1).hide(); $(".next-step").click(function() { var isValid = validateCurrentStep(); if (isValid) { saveCurrentStepData(); // if (currentStep < 17) { if (currentStep < totalSteps) { $(".step-" + currentStep).addClass("animate__animated animate__fadeOutLeft"); currentStep++; setTimeout(function() { $(".step").removeClass("animate__animated animate__fadeOutLeft").hide(); $(".step-" + currentStep).show().addClass("animate__animated animate__fadeInRight"); updateProgressBar(); }, 500); $(this).prop('disabled', false); } } }); $(".prev-step").click(function() { if (currentStep > 1) { if(currentStep==8 && $('input[name="electronic_selfbill"]:checked').val()=="SelfBill"){ $(".step-" + currentStep).addClass("animate__animated animate__fadeOutRight"); currentStep-=2; setTimeout(function() { $(".step").removeClass("animate__animated animate__fadeOutRight").hide(); $(".step-" + currentStep).show().addClass("animate__animated animate__fadeInLeft"); updateProgressBar(); }, 500); }else{ $(".step-" + currentStep).addClass("animate__animated animate__fadeOutRight"); currentStep--; setTimeout(function() { $(".step").removeClass("animate__animated animate__fadeOutRight").hide(); $(".step-" + currentStep).show().addClass("animate__animated animate__fadeInLeft"); updateProgressBar(); }, 500); } } }); updateProgressBar = function() { // var progressPercentage = ((currentStep - 1) / 2) * 100; var progressPercentage = ((currentStep - 1) / (totalSteps - 1)) * 100; $(".progress-bar").css("width", progressPercentage + "%"); } if(($('#saved_progress').val()!="")){ displayStep(Number($('#saved_progress').val())+1); } function validateCurrentStep() { var isValid = true; var currentStepFields = $(".step-" + currentStep).find("[required], [minlength], [maxlength]"); currentStepFields.each(function () { var field = $(this); var fieldType = field.attr('type'); var fieldValue = field.val(); var minLength = field.attr('minlength'); var maxLength = field.attr('maxlength'); if (fieldType === 'radio') { var radioGroupName = field.attr('name'); if (!$('input[name="' + radioGroupName + '"]:checked').length) { isValid = false; highlightField(field); } } else if (fieldType === 'checkbox') { var checkboxGroup = $('input[name="' + field.attr('name') + '"]'); if (!checkboxGroup.is(':checked')) { isValid = false; highlightField(field); } else { removeHighlight(field); } } else { if (fieldValue.trim().length === 0 || (minLength && fieldValue.length < parseInt(minLength)) || (maxLength && fieldValue.length > parseInt(maxLength))) { isValid = false; highlightField(field); } else { removeHighlight(field); } } }); return isValid; } function highlightField(field) { field.addClass('highlight-error'); // Scroll to the first invalid field // $('html, body').animate({ // scrollTop: field.offset().top - 50 // }, 500); field.one('input change', function () { removeHighlight(field); }) } function removeHighlight(field) { field.removeClass('highlight-error'); } }); // End Stepper Script // Field Hide Show document.getElementById("PremiumDeductFreq").addEventListener("change", function() { var pdfSelect = document.getElementById("PremiumDeductFreq"); var pdfSelectOtherInput = document.getElementById("PDFOtherText"); if (pdfSelect.value === "Other") { pdfSelectOtherInput.style.display = "block"; } else { pdfSelectOtherInput.style.display = "none"; } }); document.getElementById("BBABillingFreq").addEventListener("change", function() { var bbaSelect = document.getElementById("BBABillingFreq"); var bbaSelectOtherInput = document.getElementById("BBAOtherText"); if (bbaSelect.value === "Other") { bbaSelectOtherInput.style.display = "block"; } else { bbaSelectOtherInput.style.display = "none"; } }); const input = document.querySelectorAll(".input"); const inputField = document.querySelector(".inputfield"); const submitButton = document.getElementById("submit"); let inputCount = 0, finalInput = ""; //Update input const updateInputConfig = (element, disabledStatus) => { element.disabled = disabledStatus; if (!disabledStatus) { element.focus(); } else { element.blur(); } }; input.forEach((element) => { element.addEventListener("keyup", (e) => { e.target.value = e.target.value.replace(/[^0-9]/g, ""); let { value } = e.target; if (value.length == 1) { updateInputConfig(e.target, true); if (inputCount <= 6 && e.key != "Backspace") { finalInput += value; if (inputCount < 6) { updateInputConfig(e.target.nextElementSibling, false); } } inputCount += 1; } else if (value.length == 0 && e.key == "Backspace") { finalInput = finalInput.substring(0, finalInput.length - 1); if (inputCount == 0) { updateInputConfig(e.target, false); return false; } updateInputConfig(e.target, true); e.target.previousElementSibling.value = ""; updateInputConfig(e.target.previousElementSibling, false); inputCount -= 1; } else if (value.length > 1) { e.target.value = value.split("")[0]; } submitButton.classList.add("hide"); }); }); window.addEventListener("keyup", (e) => { if (inputCount > 6) { submitButton.classList.remove("hide"); submitButton.classList.add("show"); if (e.key == "Backspace") { finalInput = finalInput.substring(0, finalInput.length - 1); updateInputConfig(inputField.lastElementChild, false); inputField.lastElementChild.value = ""; inputCount -= 1; submitButton.classList.add("hide"); } } }); const validateOTP = () => { alert("Success"); }; //Start function saveCurrentStepData() { if (currentStep === totalSteps) { // Only perform validation on the last step const allFieldsFilled = validateAllFieldsFilled(); if (!allFieldsFilled) { return; } } const formData = new FormData(); $(".step-" + currentStep + " input[type='hidden'], .step-" + currentStep + " select, .step-" + currentStep + " input.form-control, .step-" + currentStep + " input[type='radio']:checked, .step-" + currentStep + " input[type='checkbox'], .step-" + currentStep + " input[type='file']").each(function() { const fieldType = $(this).prop('type'); const fieldName = $(this).attr('name'); if (fieldType === 'file') { formData.append(fieldName, $(this)[0].files[0]); } else { let fieldValue; if (fieldType === 'radio' || fieldType === 'checkbox') { fieldValue = $(this).is(':checked') ? $(this).val() : ''; } else if (fieldType === 'select-one' || fieldType === 'select-multiple') { fieldValue = $(this).find('option:selected').val(); } else { fieldValue = $(this).val(); } // if (formData.has(fieldName)) { // console.log({fieldName,fieldValue}); // // if (!Array.isArray(formData.get(fieldName))) { // formData.set(fieldName, [formData.get(fieldName)]); // } formData.append(fieldName, fieldValue); // } else { // formData.set(fieldName, fieldValue); // } } }); formData.set('_token', $('meta[name="csrf-token"]').attr('content')); formData.set('group_id', $("#group_id").val()); if(currentStep===totalSteps){ $(".step-3 input[type='file'], .step-8 input.form-control").each(function() { const fieldType = $(this).prop('type'); const fieldName = $(this).attr('name'); const fieldValue = $(this).val(); if (fieldType === 'file') { formData.append(fieldName, $(this)[0].files[0]); } else { // For non-file inputs (assuming they are for medical plan names) if (fieldName === 'G3MedicalPlanName' || fieldName === 'G1MedicalPlanName' || fieldName === 'G2MedicalPlanName') { formData.append(fieldName, fieldValue); } } }); $(".step-11 input[type='file']").each(function() { const fieldType = $(this).prop('type'); const fieldName = $(this).attr('name'); const fieldValue = $(this).val(); formData.append(fieldName, $(this)[0].files[0]); }); } $('#submitButton').prop("disabled", true); $('#submitButton').text("saving..."); console.log(formData); $.ajax({ url: '/save-current-step-data', method: 'POST', data: formData, processData: false, // Prevents jQuery from automatically processing the data contentType: false, // Prevents jQuery from automatically setting the content type success: function(response) { $('#submitButton').prop("disabled", false); $('#submitButton').html(" Submit"); console.log('Step data saved successfully'); $("#group_id").val(response.group_id); $("#item" + response.currentStep).val(response.item_id); toastr.success('Progress Saved Successfully!') toastr.options.closeDuration = 50; if (response.currentStep == totalSteps) { Swal.fire({ title: "Intake Complete!", html: "Thank you for submitting your group paperwork!
" + "You will soon receive an email containing a link to confirm and sign the documents.
" + "Once completed, a member of our NAS Agent Concierge Team will review your submission for processing.
" + "If you encounter any issues or do not receive the email, please reach out to our agent Concierge team at"+ "
sales@nationalagencysolutions.com
or
+1 (866) 744 1531.", icon: "success", showConfirmButton: false, allowOutsideClick: false, footer: '' }); document.getElementById('goToDashboard').onclick = function() { window.location.href = "/dashboard"; }; } }, error: function(xhr, status, error) { $('#submitButton').prop("disabled", false); $('#submitButton').html(" Submit"); console.error('Error saving step data:', error); toastr.error('Something Went Wrong!') } }); } function handleStep12() { var formData = new FormData(); // Collect values from input fields var userFirstName = []; var userEmail = []; var userCheck1 = []; var userCheck2 = []; var userCheck3 = []; Array.from(document.querySelectorAll('input[name="UserFirstName\\[\\]"]')).forEach(function(input) { userFirstName.push(input.value); }); Array.from(document.querySelectorAll('input[name="UserEmailAddress\\[\\]"]')).forEach(function(input) { userEmail.push(input.value); }); Array.from(document.querySelectorAll('select[name="userEmployed\\[\\]"]')).forEach(function(select) { userCheck1.push(select.value); }); Array.from(document.querySelectorAll('select[name="userEligible\\[\\]"]')).forEach(function(select) { userCheck2.push(select.value); }); Array.from(document.querySelectorAll('select[name="userBalance\\[\\]"]')).forEach(function(select) { userCheck3.push(select.value); }); // Rearrange data for (var i = 0; i < userFirstName.length; i++) { var obj = { 'UserFirstName': userFirstName[i], 'userEmail': userEmail[i], 'userEmployed': userCheck1[i] || 'no', 'userEligible': userCheck2[i] || 'no', 'userBalance': userCheck3[i] || 'no' }; // Append each key-value pair to formData for (var key in obj) { formData.append(key, obj[key]); } } // Add CSRF token and group ID formData.append('_token', document.querySelector('meta[name="csrf-token"]').getAttribute('content')); formData.append('group_id', document.getElementById("group_id").value); $.ajax({ url: '/save-current-step-data', method: 'POST', data: formData, processData: false, // Prevents jQuery from automatically processing the data contentType: false, // Prevents jQuery from automatically setting the content type success: function(response) { $('#submitButton').prop("disabled", false); $('#submitButton').html(" Submit"); console.log('Step data saved successfully'); $("#group_id").val(response.group_id); $("#item" + response.currentStep).val(response.item_id); toastr.success('Progress Saved Successfully!'); toastr.options.closeDuration = 50; }, error: function(xhr, status, error) { $('#submitButton').prop("disabled", false); $('#submitButton').html(" Submit"); console.error('Error saving step data:', error); toastr.error('Something Went Wrong!'); } }); } function showlocations(obj) { var value; if (obj) { if ($(obj).val() === 'SeparateBill') { // If obj is passed and its value is 'SeparateBill', // get the value from the dropdown directly value = $('select[name="how_many_location"]').val(); } else { // Otherwise, get the value from obj value = $(obj).val(); } } else { // If obj is not passed, get the value from the dropdown directly value = $('select[name="how_many_location"]').val(); } for (var i = 2; i <= 10; i++) { if (value >= i) { $(`#location_${i}`).show().find('input, input[type="radio"]').prop('required', true); } else { $(`#location_${i}`).hide().find('input, input[type="radio"]').prop('required', false); } } } function showClasses(obj){ var value = $(obj).val(); if(value==3){ $('#class_2').show().find('input, input[type="radio"]').prop('required', true); $('#class_3').show().find('input, input[type="radio"]').prop('required', true); }else if (value==2){ $('#class_2').show().find('input, input[type="radio"]').prop('required', true); $('#class_3').hide().find('input, input[type="radio"]').prop('required', false); }else{ $('#class_2').hide().find('input, input[type="radio"]').prop('required', false); $('#class_3').hide().find('input, input[type="radio"]').prop('required', false); } } function showHide(id, obj) { var $obj = $(obj); if ($obj.is(':radio') || $obj.is(':checkbox')) { switch (id) { case 'ProsperityCoverage': $('.' + id).toggle($obj.is(':checked') && ($obj.val() == 'yes') && ($('#current-state').val()=="Pennsylvania")); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes' && $('#current-state').val()=="Pennsylvania"); upDateFileds(obj) break; case 'EmployerEmployee': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'other'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'no'); break; case 'CDOther': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'no'); break; case 'CDOtherText': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'CDOther'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == ''); break; case 'AllCoverageSold': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'no'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'no'); break; case 'separate_benefit_contact': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'separate_billing_contact': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); upDateFiledsBillings(obj) toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'how_many_location': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'SeparateBill'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'OtherLocation': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'WrittenGeneralAgency': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'plan2': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'plan3': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'Gap2': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'Gap3': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'retiredClass': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'NumberOfClasses': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); if($('input[name="ClassInfo"]:checked').val()=="no"){ console.log('yes'); $('#class_1').hide(); $('#class_2').hide(); $('#class_3').hide(); toggleRequiredFields($(".class_1"), false); toggleRequiredFields($('.' + id), false); }else{ console.log('no'); $('#NumberOfClasses').val(1); $('#class_1').show(); toggleRequiredFields($(".class_1"), true); toggleRequiredFields($('.' + id), true); } break; case 'SexType': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'yes'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'yes'); break; case 'CensusEnrollment': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'edi'); $('.CensusEnrollment1').toggle($obj.is(':checked') && $obj.val() != 'edi'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'edi'); toggleRequiredFields('.CensusEnrollment1', $obj.is(':checked') && $obj.val() != 'edi'); break; case 'CobraSection': if($('input[name="CobraInfo"]:checked').val()=="yes"){ $('#CobraSection').show(); }else{ $('#CobraSection').hide(); toggleRequiredFields($('#CobraSection'), false); } break; case 'COBRAAdministration': $('.' + id).toggle($obj.is(':checked') && $obj.val() == 'ThirdPartyAdministered'); toggleRequiredFields($('.' + id), $obj.is(':checked') && $obj.val() == 'ThirdPartyAdministered'); break; case 'anniversary_date': if($('input[name="CafeteriaPlan"]:checked').val()=="yes"){ $('#anniversary_date').show(); }else{ $('#anniversary_date').hide(); toggleRequiredFields($('#anniversary_date'), false); } break; case 'benefit-fields': $(obj).closest('.locationDublicateClass').find('.' + id).toggle($obj.is(':checked') && $obj.val() == 'Yes'); toggleRequiredFields($(obj).closest('.locationDublicateClass').find('.' + id), $obj.is(':checked') && $obj.val() == 'Yes'); populatBenifitFields(obj); break; case 'orgTypeOther': if($('input[name="OrganizationType"]:checked').val()=="Other"){ $('#orgTypeOther').show(); }else{ $('#orgTypeOther').hide(); } case 'electronic_selfbill_div': if($obj.is(':checked') && $obj.val() == 'SelfBill'){ $('.' + id).show(); toggleRequiredFields($('.' + id), true); }else{ $('.' + id).hide(); toggleRequiredFields($('.' + id), false); } break; default: $('.' + id).hide(); toggleRequiredFields($('.' + id), false); } } else if ($obj.is('select')) { switch (id) { case 'PDFOtherText': var val = $obj.val(); $('.' + id).toggle(val == 'Other' || val == 'BiWeekly' || val == 'Weekly'); $('.PDFPayPeriodStart').toggle(val == 'Other' || val == 'BiWeekly' || val == 'Weekly'); toggleRequiredFields($('.' + id), val == 'Other' || val == 'BiWeekly' || val == 'Weekly'); toggleRequiredFields($('.PDFPayPeriodStart'), val == 'Other' || val == 'BiWeekly' || val == 'Weekly'); break; case 'BBAOtherText': $('.' + id).toggle($obj.val() == 'Other'); toggleRequiredFields($('.' + id), $obj.val() == 'Other'); break; default: $('.' + id).hide(); toggleRequiredFields($('.' + id), false); } } else { console.error("Object is neither a checkbox, radio button, nor a select element."); } } function validatePlanName(input) { var planNameInputs = document.querySelectorAll('.planName'); var planNames = Array.from(planNameInputs).map(function(input) { return input.value.trim().toLowerCase(); }); var index = Array.from(planNameInputs).indexOf(input); if (index !== -1) { planNames.splice(index, 1); } var inputValue = input.value.trim().toLowerCase(); var isDuplicate = planNames.includes(inputValue); if (isDuplicate) { alert('Plan name must be unique.'); input.value = ''; input.focus(); } } function dublicateDiv(obj,id,className){ var count = parseInt(obj.value); console.log(count); var container = document.getElementById(id); var originalDiv = document.querySelector("."+className); container.innerHTML = ''; for (var i = 0; i < count; i++) { var clone = originalDiv.cloneNode(true); clone.style.display = "block"; // Show the cloned div container.appendChild(clone); } } function upDateFileds(obj){ console.log($(obj).val()); if($(obj).val()=='no'){ var execContactName = $('#ExecutiveContactName').val(); var execTitle = $('#ExecutiveTitle').val(); var execEmailAddress = $('#ExecutiveEmailAddress').val(); var execPhoneNumber = $('#ExecutivePhoneNumber').val(); // Set values in corresponding benefit fields $('#BenefitContactName').val(execContactName); $('#BenefitTitle').val(execTitle); $('#BenefitEmailAddress').val(execEmailAddress); $('#BenefitPhoneNumber').val(execPhoneNumber); } else { // Empty the benefit fields $('#BenefitContactName').val(''); $('#BenefitTitle').val(''); $('#BenefitEmailAddress').val(''); $('#BenefitPhoneNumber').val(''); } } function upDateFiledsBillings(obj){ if($(obj).val()=='no'){ var execContactName = $('#ExecutiveContactName').val(); var execTitle = $('#ExecutiveTitle').val(); var execEmailAddress = $('#ExecutiveEmailAddress').val(); var execPhoneNumber = $('#ExecutivePhoneNumber').val(); // Set values in corresponding benefit fields $('#BillingContactName').val(execContactName); $('#BillingTitle').val(execTitle); $('#BillingEmailAddress').val(execEmailAddress); $('#BillingPhoneNumber').val(execPhoneNumber); } else { // Empty the benefit fields $('#BillingContactName').val(''); $('#BillingTitle').val(''); $('#BillingEmailAddress').val(''); $('#BillingPhoneNumber').val(''); } } function populatBenifitFields(obj){ if($(obj).val() == 'No'){ var l2BenefitContactName = $(obj).closest('.locationDublicateClass').find('#L2BenefitContactName').val(); var l2BenefitTitle = $(obj).closest('.locationDublicateClass').find('#L2BenefitTitle').val(); var l2BenefitEmail = $(obj).closest('.locationDublicateClass').find('#L2BenefitEmail').val(); var l2BenefitPhone = $(obj).closest('.locationDublicateClass').find('#L2BenefitPhone').val(); $(obj).closest('.locationDublicateClass').find('#L3BenefitContactName').val(l2BenefitContactName); $(obj).closest('.locationDublicateClass').find('#L3BenefitTitle').val(l2BenefitTitle); $(obj).closest('.locationDublicateClass').find('#L3BenefitEmail').val(l2BenefitEmail); $(obj).closest('.locationDublicateClass').find('#L3BenefitPhone').val(l2BenefitPhone); } else { $(obj).closest('.locationDublicateClass').find('#L3BenefitContactName').val(''); $(obj).closest('.locationDublicateClass').find('#L3BenefitTitle').val(''); $(obj).closest('.locationDublicateClass').find('#L3BenefitEmail').val(''); $(obj).closest('.locationDublicateClass').find('#L3BenefitPhone').val('') } ; } function addFields(obj) { console.log('test'); var $formGroup = $(obj).closest(".form-group"); var $newFormGroup = $formGroup.clone(); $newFormGroup.find('input[type="text"]').val(''); $newFormGroup.find('input[type="email"]').val(''); $newFormGroup.find('textarea').val(''); $formGroup.after($newFormGroup); updateButtonStates(); } function removeFields(obj) { var $formGroup = $(obj).closest(".form-group"); $formGroup.remove(); updateButtonStates(); } function updateButtonStates() { var $formGroups = $(".form-group"); var numFields = $formGroups.length; $(".add-btn").prop("disabled", numFields >= 16); $(".remove-btn").prop("disabled", numFields <= 1); } function validatePercentage(input) { let value = parseFloat(input.value); if (value > 100) { input.value = 100; } } function getDollarTiers(plan) { var employees = $('#EligibleEEMembers').val(); var rateGroup = $('#rateGroup').val(); var stateAbbreviation = $('#stateAbbreviations').val(); var state = $('#current-state').val(); var deductibleAmountField = '#' + plan + 'DeductibleAmount'; var povFieldName; switch (plan) { case 'plan1': povFieldName = 'GroupPlan1'; break; case 'plan2': povFieldName = 'GroupPlan2'; break; case 'plan3': povFieldName = 'GroupPlan3'; break; default: console.error('Invalid plan:', plan); return; // Exit function for invalid plan } var deductibleAmount = $(deductibleAmountField).val(); var povValue = $('input[name="' + povFieldName + '"]:checked').val(); if(plan=='plan1' && povValue=="G1POV"){ $("input[name='PhysicianOfficeVisits']").prop("checked", true); $("input[name='IncludesChiropracticServices']").prop("checked", true); }else{ $("input[name='PhysicianOfficeVisits']").prop("checked", false); $("input[name='IncludesChiropracticServices']").prop("checked", false); } if(povValue!=null && deductibleAmount!=null){ NProgress.start(); $('#overlay').show(); // Get CSRF token value var csrfToken = $('meta[name="csrf-token"]').attr('content'); // Prepare data object var data = { deductibleAmount: deductibleAmount, employees: employees, state: state, povValue: povValue, rateGroup:rateGroup, stateAbbreviation:stateAbbreviation }; $.ajax({ url: '/get-dollars', method: 'POST', headers: { 'X-CSRF-TOKEN': csrfToken }, data: data, success: function(response) { var benefitAmountField = '#' + plan + 'BenefitAmount'; var $benefitAmount = $(benefitAmountField).empty(); $benefitAmount.append($(''); // Add default option $.each(data, function(index, benefit) { $select.append($('