I have added custom JavaScript to a powerapps portal web page, the code I am using shows a field 2 when a particular selection (Yes) is made in field 1, field 2 does not appear on the form if no selection is made in field 1. The issue I am havig is field 2 is not mandatory and the code is using .prop("required",true).
Field 1 is a dropdown field with the options Blank (before section) Yes or No.
Field 2 is a multiselect field with 4 options.
The show/hide element of the code is working correctly just not the mandatory step to make the user select an option in field 2 before moving to the next page.
This is my code:
// if Sec C Q1 SC = Yes show Q2
$(document).ready(function() {
$("#recordclinical").change(SetFieldsVisibilityQC1);
$("#recordclinical").change();
});
function SetFieldsVisibilityQC1() {
var selectedValue = $("#recordclinical").val();
if (selectedValue === "352230000")
{
$("#recorded_label").closest("tr").show();
$("#recorded").prop("required",true).closest("tr").show();
$("#otherspecify_label").closest("tr").show();
$("#otherspecify").prop("required",false).closest("tr").show();
}
else
{
$("#recorded_label").closest("tr").hide();
$("#recorded").prop("required",false).closest("tr").hide();
$("#otherspecifyd_label").closest("tr").hide();
$("#otherspecify").prop("required",false).closest("tr").hide();
}
}
any advice what on what I am missing.