We have a form where we prefill a lot of the fields in code. We only display a subset of the fields in the form, depending on the scenario.
We’ve run into an issue where we populate a hidden people picker field with an old value that is no longer valid. We want to be able to identify that the field is invalid and fix the issue without requiring the user to take any action. For this case, we can just clear the field.
You can use something like this after you have filled in all the fields:
var fin = jQuery(elm).parents("tr:first").attr("fieldinternalname");
console.log("There is a validation error in this field: " + fin);