Both of them
The simple fact of highlighting a field makes it easily noticeable when the user needs to correct it, but it does not give the user any context as to why it is highlighted, for example, if a password field is highlighted, this could be a series of problems in As to why he stood out. . This can also cause accessibility problems, especially if you are relying on color only as the highlight. Just highlighting without a textual context will only cause confusion and could cause users to leave it.
The simple fact of adding online form validation is excellent for the context of what the error is, but while it is located between other fields and field headers, it may be less easy to detect.
I would recommend both for efficiency so that the user completes it faster.
For more information read this.