In our Angularjs Application, we set the required Fields dynamically (ng-required). Therefore it is a quite complicated to add an *
to the label every time it is required.
Now we have another idea. It may be possible to mark the input-field itself as required. In this post, we found a part of the solution.
There were CSS-Selectors for a required field, so we can set a Background-Image for that like this:
<!-- language: lang-css -->input:required:valid {
background-image: url(valid.png);
background-position: right center;
background-repeat: no-repeat;
}
input:required:invalid {
background-image: url(invalid.png);
background-position: right center;
background-repeat: no-repeat;
-moz-box-shadow: none;
}
<!-- language: lang-html -->
<p>Name:</p>
<input type="text" name="name" required />
But using that way, we need a background image of an *
, And this seems to be very hacky. Especially, if there are different Sizes of the form, so the Image has different resolutions.
Than we found this (Section Labeled) example and it seems to be possible to add Text to the input field.
So the question is, how can I put that all together, so that I can put an glyphicon from twitter-bootstrap to the right side of an input field, if that is required without editing all my forms?
Hers a jsFiddle. That might work, but the problem is, that background-size is not supported everywhere.