【问题标题】:JQuery - Require a Form Field if VisibleJQuery - Require a Form Field if Visible
【发布时间】:2022-12-01 15:19:10
【问题描述】:

I'm using the Jquery code below for a webform in Power App Portals. The code hides theBIL Categorydrop-down field based on the choice selected in theType of Funding Requestdrop-down field. This all works perfectly.

Now I simply want to require theBIL Categoryfield if it is visible. How can I modify the code to achieve this?

$(document).ready(function () {
     $("#cr92d_typeoffundingrequest").change(onDisplaySectionChange);
     onDisplaySectionChange();
});

function onDisplaySectionChange() {
    var varFunding = $('#cr92d_typeoffundingrequest').find("option:selected").text();
    if (varFunding === "DWSRF") 
    
    {
    $('#cr92d_bilcategory').parent().parent().hide();
    }
    else{$('#cr92d_bilcategory').parent().parent().show();
}
}

【问题讨论】:

标签: javascript jquery powerapps


【解决方案1】:
    else
{
    $('#cr92d_bilcategory').parent().parent().show();
    $('#cr92d_bilcategory').prop('required', true);     
   $('#cr92d_bilcategory').closest(".control").prev().addClass("required");
    }

Try this.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-26
    • 2022-12-01
    • 1970-01-01
    • 2022-12-02
    • 2011-01-28
    • 2021-09-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多