<style type="text/css"> input:valid { background-color: #FFFF00; } </style> <form> <input type="text" minlength="5" required> </form>