For anyone else reading this, I figured out a way to make this work by continuously looking for the form's error field inside the iframe then calling my function to resize if it's present:
var foundFormError = false;
window.setInterval(
function() {
if (!foundFormError) {
var ctas = document.querySelectorAll(`iframe[id^="cta-iframe"]`);
ctas.forEach(cta => {
var iframeContent = document.getElementById(cta.id).contentWindow.document;
if (iframeContent.getElementsByClassName('field-error').length > 0) {
foundFormError = true;
// resize here!
}
});
}
},
100);