I have an AngularJS and Bootstrap app, although I'm not sure if this is relevant. I want to define a CSS style for required fields. I see many examples if the field has class='required' , for example here :
.form-group.required .control-label:after { content:"*"; color:red; }
However, is it possible to do the same if the field has required='required' but does not have the required class?
Typically, I have a field that is conditionally required using ng-required='chkChecked' , and although I can add ng-class={'required': chkChecked} , I would prefer to avoid it if possible
Refresh for clarification only. I want to create a field if it has a required attribute, regardless of whether it has a required class. My initial question can be interpreted that I want to style an element if it is required, but does not have the required class. This is not true. Unfortunately.
In addition, I would prefer to put an asterisk on the label attached to the input field, rather than, say, a red border attached to the field itself (which can be done using input[:required] (which I did not know about). I tried .form-group:required , but for some reason does nothing, although I see <div class="form-group" required="required"> in F12
angularjs css css3 twitter-bootstrap twitter-bootstrap-3
Felix
source share