Dan*_*iKR 4 css validation message twitter-bootstrap
我正在为我的Web应用程序使用bootstrap,我在验证消息时遇到问题,因为它将消息状态置于正确的位置.现在我在此链接中使用此示例,使用以下代码:
<div class="control-group error">
<label class="control-label" for="inputError">Input with error</label>
<div class="controls">
<input type="text" id="inputError">
<span class="help-inline">Please correct the error</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在我使用的代码:
<h4 class="form-signin-heading">Please sign in</h4>
<div class="control-group">
<div class="controls">
@Html.TextBoxFor(u => u.Username, new {placeholder="Username", @class="form-control username", id="inputError"})
<span class="help-inner">@Html.ValidationMessageFor(u => u.Username)</span>
</div>
<div class="controls">
@Html.PasswordFor(u => u.Password, new {placeholder="Password", @class="form-control password"})
@Html.ValidationMessageFor(u=> u.Password)
</div>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
Run Code Online (Sandbox Code Playgroud)
我的代码执行此操作(也在小提琴中:http://jsfiddle.net/4h5E5/1/):

但我的不满是将验证消息放在这个位置(如链接中的示例):

请检查这个JS Fiddle Link
HTML代码:
<!DOCTYPE html>
<body>
<div class="container">
<form class="form-signin form-horizontal" role="form">
<h4 class="form-signin-heading">Please sign in</h4>
<div class="form-group">
<div class="col-xs-7 col-sm-7">
<input type="username" class="form-control username" placeholder="Username" required="autofocus" />
</div>
<div class="col-xs-7 col-sm-5"> <span class="help-inline pull-left">Please correct the error</span>
</div>
</div>
<div class="form-group">
<div class="col-xs-7 col-sm-7">
<input type="password" class="form-control password" placeholder="Password" />
</div>
<div class="col-xs-7 col-sm-5"> <span class="help-inline pull-left">Please correct the error</span>
</div>
</div>
<div class="form-group">
<div class="col-xs-7 col-sm-7">
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</div>
</div>
</form>
</div>
<!-- /container -->
<!-- Bootstrap core JavaScript==================================================- ->
<!-- Placed at the end of the document so the pages load faster -->
</body>
Run Code Online (Sandbox Code Playgroud)
我希望这是你想要实现的目标.
如果您有任何其他问题或未解决,请在下面添加评论.
问候D.
| 归档时间: |
|
| 查看次数: |
7236 次 |
| 最近记录: |