In this blog, you learn about the Powerapps portal field mandatory.
ument).ready(function () { var registrationOption = $('#vwi_registrationportaluserrole').val(); if(registrationOption==1) { MakeRequired("new_field"); } else { MakeNotRequired("new_field"); } );} //Make mandatory field var MakeRequired = function (fieldName) { try { if ($("#" + fieldName) != undefined) { $("#" + fieldName).prop('required', true); $("#" + fieldName).closest(".control").prev().addClass("required"); // Create new validator var Requiredvalidator = document.createElement('span'); Requiredvalidator.style.display = "none"; Requiredvalidator.id = fieldName + "Validator"; Requiredvalidator.controltovalidate = fieldName; Requiredvalidator.errormessage = "<a href='#" + fieldName + "_label'>" + $("#" + fieldName + "_label").html() + " is a required field.</a>"; Requiredvalidator.initialvalue = ""; Requiredvalidator.evaluationfunction = function () { var value = $("#" + fieldName).val(); if (value == null || value == "") { return false; } else { return true; } }; // Add the new validator to the page validators array: Page_Validators.push(Requiredvalidator); } } catch (error) { errorHandler(error); } } //Make UnMandatory var MakeNotRequired = function (fieldName) { try { if ($("#" + fieldName) != undefined) { $("#" + fieldName).closest(".control").prev().removeClass("required"); $("#" + fieldName).prop('required', false); for (i = 0; i < Page_Validators.length; i++) { if (Page_Validators[i].id == fieldName + "Validator") { Page_Validators.splice(i); } } } } catch (error) { errorHandler(error); } }
Read More