javascript – How to validate an entry when its content changes?

I liked the fact that when I filled a given input, it was validated, that is, when I filled a field "nif", I was alerted by a message & # 39; nif & # 39; invalid until it is correct and that it is no longer necessary to use methods such as onBlur to do it.

Does anyone know of one way to do that?

My code