How to stop redirecting users to wp-comments-post.php when receiving an error and display a popup instead

I have a website that allows comments on posts and reviews on woocommerce products.
However, the comment form, if not filled out correctly will automatically redirect users to /wp-comments-post.php to display the error. See image for error.

I want to display any errors like this in a simple popup alert box rather than users seeing WordPress error pages. What is the best way to implement this?

enter image description here