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:
any advice what on what I am missing.
Are you just setting the 'required' property of these fields? As far as I know, that does not prevent a portal user from submitting the form.
You could add a Custom Page Validator, as described here.
For the validation function you could just use RequiredFieldValidatorEvaluateIsValid instead of a custom function.
To mark the field as required, you can use something like
$("#id_of_field2").closest("td").find("div.info").addClass("required");
Don't forget to remove the validator if the field is no longer required based on user input
I have removed that and its still not working. Also, I am not able to use metadata as the field doesn't appear in the list, this maybe because it is an multiselect field.
Field 2 is set as optional at dataverse level because its only required if field 1 is yes. Currently no metadata set, I set the field required using the metadata but this only makes it required all the time even when its not visible (i.e. field 1 is no).
Hi, is the field 2 mandatory at the dataverse level? or can you check if there is any form metadata associated with the field making it required?
Fubar
69
Super User 2025 Season 1
oliver.rodrigues
49
Most Valuable Professional
Jon Unzueta
43