We followed the code as per post -
Solved: Conditionally setting fields to mandatory - Power Platform Community (microsoft.com)
This works fine and we are able to show/hide a single text field (and also make it required) when another field is set to "Other" -
This is fine so far. But then I realized that since this is only a client side JS, this can of course be overidden.
I ran the following in the console and yes, the validation has disappeared. We run it multiple times until Page_Validators is emptied.
for (i = 0; i < Page_Validators.length; i++) {
Page_Validators.splice(i, 1);
}
On the other hand, if we use form metadata to make a field required, it not only adds to the page_validator but also checks at the server side.
Hence, we would like dynamic validations but at the server side. In our project we have done a lot of different client side javascripts based on recommendations from the community but we feel that is a big area of concern.
For server side you would have to write them in Plugin code, or could use realtime Workflow's for very simple stuff. If you do this you also need to set the site setting below to true, and in your plugin error output/throw a 'nice' message, (for Workflow Stop step as error with nice message)
Site/EnableCustomPluginError set to true
Fubar
69
Super User 2025 Season 1
oliver.rodrigues
49
Most Valuable Professional
Jon Unzueta
43