I am trying to do something that in my head is very simple, but all my attempts to make it happen have failed.
Using ng-model
and $setValidity()
, I can make any field valid or invalid and angular will add the 'ng-invalid' class to any invalid fields, which is great. I'm using bootstrap, which has built-in styles for 'input:invalid', which adds a red border around all invalid elements when those elements are in focus.
My problem is that I would like to add a ***
after every input in my form that is invalid so that the user can quickly see which fields need to be fixed. I thought I could do that using only CSS by doing the following:
input.ng-invalid{
border: 2px solid red;
}
input.ng-invalid:after{
content: '***';
}
I have an plunker that demonstrates a simple example of this here. The example <input>
is required, so if you just remove the text from the field, it immediately becomes invalid and gets a big red border. But it doesn't get the content: '***';
style.
Do I just not understand how the :after
selector works in CSS? Or am I doing something else wrong? Any pointers would be greatly appreciated. Thanks!