You don't need dynamic css for this. All you need is to have a boolean variable with a value if your validation failed or not, and then you can use mendix's conditional visibility on two containers.
One container with a class which has it’s css altered with your highlighted colour, and the other container without a class (so it looks like the default of the app)
if you still want to look at actual dynamic css there's the stylesheet switcher available here: https://appstore.home.mendix.com/link/app/106033/
html snippets with context rendering a child style tag based off the context or request handler/rest service serving up some table with a field for your css