We have Field 1, which populates Field 2 via lookups.
Field 2 has a regex. If the value that is looked up does not match the regex, it should flag the field as invalid and prevent submission.
This works fine if the field is editable. However, when we change it to read-only, it breaks. No error is displayed and the form can be submitted. Backend validation catches it, but we don't want that. We want to prevent submission.
I tried to trigger the change event on the field manually when it is populated:
$("#Field2").on("change", function() { $(this).trigger("change"); });
This makes it so that the invalid input message is shown, but the form can still be submitted.
tl;dr: Read-only fields populated via lookups have their regex rules ignored. How do I make it work with zero custom JavaScript?