How to add required indication(*) in bootstrap form?

You can easily add asterisk (*) to the required field in bootstrap form fields. Add the below CSS to your page.

CSS:
.form-group.required .control-label:after
{
      content:"*";
      color:red;
}
Then add an additional 'required' class to the 'form-group' class.
<form>
      <div class="form-group required">
        <label class="control-label">Username</label>
        <input type="text" name="userName"/>
      </div>
</form>
final code and demo is here

Demo

No comments:

Post a Comment