Is there a JS event that my own custom code can listen for to determine that client-side / browser validation of a form has passed?
i.e. That no messages like this have occurred: "Please fill in this field" because a field was empty.
If there such an event that can be listened to then my own JS could handle the POST submission and then replace the form with a thank you message, in-situ / in place on the same page.
What I don't want to do is have my code run whether the form submission input by the user is valid or not. In other words I don't want to display a thank you message if they've not given valid data. That's why I need an event to say validation passed.
This to me is a better solution to say "thank you" rather than redirecting to content that can itself be indexed and accessed "outside" of the form submit situation, even if a module like rabbit_hole is used.
Looking for a Drupal 8 or 9 solution for myself but tagged with 7 to encourage answers for those who also might want an answer but for Drupal 7.