我尝试找到无效信息内联输入。
我添加了错误消息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;
答案 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;
}