When the onValidate is triggered, it checks if the fields contain the correct data - if not, the Icon property is set (to a red arrow) - thus marking the field that contains invalid data.
However - when triggering the Set-UDElement, another onValidate is triggered - thus starting an endless loop of onValidate events. Causing browser to spike in CPU usage.
I would suggest using a dummy element outside of the form’s inputs, and using the validation failure hook to replace the content with the icon.
If you are using the New-UDGrid cmdlets for layout on the form, it should be pretty easy to adjust the column structure to allow room for, say, a New-UDElement -Tag "div" -Id "subjectIcon", which can then be edited in the following ways:
# For your use case this is likely unnecessarily verbose.
# You can use other means, but the general structure here is
# hopefully helpful.
$elementChildren = (Get-UDElement -Id "subjectIcon").Content
foreach ($child in $ElementChildren ) {
Remove-UDElement -Id $child.Id
}
Please let me know if this works; since you aren’t editing properties of input types, this shouldn’t trigger onValidate, but I may be wrong. This is all theoretical at this point. ZG