I'm trying to catch error: An invalid form control with name is not focusable.
It occurs when I submit a form and there's a field required with display none;
I would like to get the field that is invalid and show in the screen.
I've tried to simulate submit button click like:
try {
btn.click();
} catch (e) {
[...]
}
But it doesn't enter on catch, even when logs show the error;
I've already tried both of codes:
window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {
alert("Error occured: " + errorMsg);//or any message
return false;
}
window.addEventListener("error", function (e) {
alert("Error occurred: " + e.error.message);
return false;
})
But it doesn't catch the error too.