Showing a red alert text near an input if the input does not match what we want

So basically I want to display some red text in a website if the content of an input is not what I want the person to put
I know how to check for that with jquery, but to show the red text I was thinking of having it already in the html with a hidden class and then removing the hidden class when the input is not correct, but it seems a bit dirty ? Is there a better way to make some text appear in that case ?