Automate

 View Only

Javascript - Conditionally Remove Dropdown Requirement and Invalid Option Warning

  • 1.  Javascript - Conditionally Remove Dropdown Requirement and Invalid Option Warning

    Posted 23 hours ago

    I have a Country & Region field. Both are required fields.

    Region's data is based on what is entered into the Country field. Select US as Country.... Region is all the state names

    I have some Countries that do not have any Regions so I would like to dynamically remove the dropdown requirements and invalid option warning from the Regions filed using javascript.  

    I can remove the frm_required and I can also set text-danger to "" <div class="text-danger">Invalid Option: WA</div> however when I click the submit button the "Invalid Option: WA" text reappears.

    What is the method to remove the text-danger so on Submit it doesn't reappear.

    Thanks,

    Kurt

        if (missingRegion.includes(searchItem)) {
            $form.setControlRequired('/my:myFields/my:ff_Region', false);
            $j("#content_frm_element_11280").removeClass("frm_required");
            setTimeout(function () {$j('#frm_element_11280 .text-danger').remove();}, 200);
            //$j("#content_frm_element_11280 .text-danger").removeClass("text-danger");
            //wsremoveError('/my:myFields/my:ff_Region');
        } else {
            $form.setControlRequired('/my:myFields/my:ff_Region', true);
        }

    <div type="control_dropdown" class="form-control-wf" id="frm_element_11280" data-cid="frm_element_11280" data-corigid="frm_element_11280">
    <div id="content_frm_element_11280">
    <div id="frm_label_80" class="form-label form-label-top frm_required" style="z-index: 100;">
    <span class="form-label-span editable">Region</span>
    </div>
    <div class="control-body" style="display:inline-block;width:100%">
    <div class="control-boxsize" style="width:100%">
    <span class="form-sub-label-container" style="width:100%">
    <select id="frm_component_select1_80" data-link="my_myFields.my_ff_Region.ws_text" class="form-component form-dropdown dropdown required_field" type="text" maxlength="6" style="">
    <option value="">No Region</option>
    </select>
    <label id="frm_component_label1_80" class="form-component form-sub-label sublabel "></label>
    </span>
    <div class="text-danger">Invalid Option: WA</div>
    </div>
    </div>
    </div>
    </div>


    ------------------------------
    Kurt Marshman
    Old World Industries, LLC
    ------------------------------