无效消息内联输入

时间:2017-08-17 06:29:49

标签: html css angularjs

我尝试找到无效信息内联输入。
我添加了错误消息style="display:inline"但它无效。

我该怎么办?



<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<form name="pniyaForm">
   <div class="row form-inline">
      <div class="col-sm-12 form-group has-feedback">
          <label for="mail">Mail:</label>
          <input name="mailParent" ng-class="{'has-error':pniyaForm.$submitted && pniyaForm.mailParent.$invalid}"  id="mail" type="email" ng-model="mailParent"  required/>
      </div>
      <span style="display:inline" ng-show="pniyaForm.mailParent.$invalid && (pniyaForm.mailParent.$dirty || pniyaForm.mailParent.$touched)"  ng-messages="pniyaForm.mailParent.$error">
          <div ng-message="required">required</div>
      </span>
                          
   </div>
</form>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:3)

首先,您要将span放在父div class="col-sm-12 form-group has-feedback"之外,将span置于其中,然后将inline更改为inline-block为以下内容:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<form name="pniyaForm">
  <div class="row form-inline">
    <div class="col-sm-12 form-group has-feedback">
       <label for="mail">Mail:</label>
       <input name="mailParent" ng-class="{'has-error':pniyaForm.$submitted && pniyaForm.mailParent.$invalid}"  id="mail" type="email" ng-model="mailParent"  required/>
                            
       <span style="display:inline-block" ng-show="pniyaForm.mailParent.$invalid && (pniyaForm.mailParent.$dirty || pniyaForm.mailParent.$touched)"  ng-messages="pniyaForm.mailParent.$error">
          <div ng-message="required">required</div>
       </span>
     </div>
  </div>
</form>

答案 1 :(得分:0)

display: inline-block一起输入字段和消息。

.form-inline > .form-group,.form-inline > span {
  display: inline-block;
}