/** Mark field non required */ function makeNotRequired(fieldName) { try { if ($("#" + fieldName) != undefined) { $("#" + fieldName).removeAttr('required'); $.each(Page_Validators, function (index, validator) { if (validator && validator.id === fieldName + "Validator") { Page_Validators.splice(index, 1); } }); $("#" + fieldName + "_label").parent().removeClass("required"); } } catch (error) { console.log(error); } } /** Make field required. */ function makeRequired(fieldName) { try { if ($("#" + fieldName) != undefined) { //$("#" + fieldName).prop('required', true); $("#" + fieldName).closest(".control").prev().addClass("required"); // Create new validator var Requiredvalidator = document.createElement('span'); Requiredvalidator.style.display = "none"; Requiredvalidator.id = fieldName + "Validator"; Requiredvalidator.controltovalidate = fieldName; if(fieldName.includes("_datepicker_description")) { Requiredvalidator.errormessage = "" + $("#" + fieldName.replace("_datepicker_description", "") + "_label").html() + " is a required field."; } else { Requiredvalidator.errormessage = "" + $("#" + fieldName + "_label").html() + " is a required field."; } Requiredvalidator.initialvalue = ""; Requiredvalidator.evaluationfunction = function () { var control = $("#" + fieldName); if (control != undefined) { // check if picklist if(control.prop('class').includes('picklist horizontal') || control.prop('class').includes('picklist vertical')) { let valueSelected = false; $(`#${fieldName} :input`).each(function() { if($(this).prop('checked')) valueSelected =true; }); return valueSelected; } else if (control.prop('class').includes('boolean-radio')) { let valueSelected = false; if($('input[id="' + control + '_0"]:checked').val() === "0" || $('input[id="' + control + '_1"]:checked').val() === "1") { //Has Data valueSelected =true; } return valueSelected; } var value = $("#" + fieldName).val(); if (value == null || value == "") { return false; } else { return true; } } else { return true; } }; // check if validator exists let isExisting = false; $.each(Page_Validators, function (index, validator) { if (validator.id === fieldName + "Validator") { isExisting = true; } }); if (!isExisting) { // Add the new validator to the page validators array: Page_Validators.push(Requiredvalidator); } } } catch (error) { console.log(error); } } function setFieldRequired(fieldName, isRequired) { if (isRequired) { makeRequired(fieldName); } else { makeNotRequired(fieldName); } } function conditionalSection(sectionName, isVisible) { var childSection = $(`fieldset[aria-label='${sectionName}']`); if (isVisible) { childSection.show(); } else { childSection.hide(); } } function conditionalField(fieldName, isVisible) { var fieldControl = $(`#${fieldName}`); if (isVisible) { fieldControl.parent().parent().show(); } else { fieldControl.parent().parent().hide(); } } function showFormLoading(isLoading) { if (isLoading) { $(`div[class="container"]`).hide(); if ($(`#form_loading_animation`).length > 0) { $(`#form_loading_animation`).show(); } else { $('#mainContent').append($(`