Косвенная проверка псевдокласса
<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
  <title>:valid</title>
  <style>
   input:invalid {
    background: #fdd; /* Красный цвет фона */
   }
   input:valid {
    background: #dfd; /* Зеленый цвет фона */
   }
  </style>
 </head>
 <body>
  <form>
     <input required type="email" name="email" pattern="\S+@[a-z]+.[a-z]+" oninput="validateComments(this)">
  </form>
<script type="text/javascript">
function validateComments(input) {
   console.log(getComputedStyle(input).backgroundColor);
}
</script>
 </body>
</html>