I'm trying to output invalid field names in a generic way. The below does this by looping through all the fields in the form and just appending to a string with the key name. It gets run when you click a submit button:
for (var key in form) {
if (key.indexOf("$") !== 0) {
if (form[key].$invalid) {
str += '- ' + key + '<br />';
}
}
}
My only issue with this is the order that the keys appear dont match the order that the fields appear on the page. I'm assuming it's related to how the fields themselves are created, since dynamically generated fields seem to appear before normal fields. I'd really like to maintain the order, but can't think of a good way to do this.
Was hoping someone would have a suggestion?