我是网络开发的新手。现在我的代码是这样的 - >
<form name="loginForm" id="loginform" class="form-horizontal" role="form" novalidate>
<div ng-show="errorMessage" class="compact-container alert text-center alert-danger col-xs-12"> {{errorMessage}}</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" ng-pattern="/^[a-z0-9]*$/" data-ng-model="formInfo.username"
value="" placeholder="username or email" required>
</div>
<div ng-show="loginForm.username.$error.pattern">
<span class="jdIdError-Color">Please use Lower case charchters</span>
</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-lock"></i></span>
<input id="login-password" type="password" class="form-control" data-ng-model="formInfo.password" name="password" required
placeholder="password">
</div>
<div style="margin-top:10px" class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<button type="submit" class="btn btn-info login-button-position" id="loginBtn" name="loginBtn" ng-disabled="!loginForm.$valid"
data-ng-click="isLoading=true;submit(loginForm)">
<span ng-hide="hideSpinner"
class="loginContainer-spinner">
<i class="fa fa-spin fa-refresh"></i>
</span>
<span class="text-white"><strong>Login</strong></span>
</button>
<!--<a id="btn-login" href="#" class="btn btn-success" data-ng-click="isLoading=true;submit(loginForm)">Login </a>-->
</div>
</div>
</form>
所以,当我给出错误消息时,它就是这样给出的
这里我删除了div,现在当我尝试使用margin稍微提取该消息时,它就不会发生了。所以,
答案 0 :(得分:0)
将错误div移出输入组div:
<form name="loginForm" id="loginform" class="form-horizontal" role="form" novalidate>
<div ng-show="errorMessage" class="compact-container alert text-center alert-danger col-xs-12"> {{errorMessage}}</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" ng-pattern="/^[a-z0-9]*$/" data-ng-model="formInfo.username" value="" placeholder="username or email" required>
</div>
<div ng-show="loginForm.username.$error.pattern">
<span class="jdIdError-Color">Please use Lower case charchters</span>
</div>
</form>
答案 1 :(得分:0)
从输入组类中删除错误div
<form name="loginForm" id="loginform" class="form-horizontal" role="form" novalidate>
<div ng-show="errorMessage" class="compact-container alert text-center alert-danger col-xs-12"> {{errorMessage}}</div>
<div style="margin-bottom: 25px" class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
<input id="login-username" type="text" class="form-control" name="username" ng-pattern="/^[a-z0-9]*$/" data-ng-model="formInfo.username"
value="" placeholder="username or email" required>
</div>
<div ng-show="loginForm.username.$error.pattern">
<span class="jdIdError-Color">Please use Lower case charchters</span>
</div>
&#13;
答案 2 :(得分:0)
Bootstrap提供&#34; help-block&#34;验证错误的类。 所以你需要包装&#39;输入组&#39;进入表单组添加添加类&#34; help-block&#34;你的跨度
请参阅下面的示例
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="container">
<form name="loginForm" id="loginform" class="form-horizontal" role="form" novalidate>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="glyphicon glyphicon-user"></i>
</span>
<input id="login-username" type="text" class="form-control" name="username" ng-pattern="/^[a-z0-9]*$/" data-ng-model="formInfo.username" value="" placeholder="username or email" required>
</div>
<div ng-show="loginForm.username.$error.pattern">
<span class="jdIdError-Color help-block">Please use Lower case charchters</span>
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="glyphicon glyphicon-lock"></i>
</span>
<input id="login-password" type="password" class="form-control" data-ng-model="formInfo.password" name="password" required placeholder="password">
</div>
<div style="margin-top:10px" class="form-group">
<!-- Button -->
<div class="col-sm-12 controls">
<button type="submit" class="btn btn-info login-button-position" id="loginBtn" name="loginBtn" ng-disabled="!loginForm.$valid" data-ng-click="isLoading=true;submit(loginForm)">
<span ng-hide="hideSpinner" class="loginContainer-spinner">
<i class="fa fa-spin fa-refresh"></i>
</span>
<span class="text-white">
<strong>Login</strong>
</span>
</button>
<!--<a id="btn-login" href="#" class="btn btn-success" data-ng-click="isLoading=true;submit(loginForm)">Login </a>-->
</div>
</div>
</form>
</div>
&#13;