[英]AngularJS UI Validate Password Fields
尝试使Angular-ui-validate与Bootstrapcss一起使用我的表单
这是HTML
<div class='container' ng-controller='RegisterController as ctrl'>
<form class="form-register" ng-submit="ctrl.register()">
<h2 class=form-user-details">General Information</h2>
<div class="form-group">
<label for="inputEmail1">Email address</label> <input type="email"
class="form-control" ng-model='inputEmail' id="inputEmail1"
placeholder="Email" required autofocus> <span
style='font-size: 10px; color: red'>Note: Your email will
serve as your username!</span>
</div>
<div class="form-group" ng-class="{'has-error': !form.confirm_password.$error.validator}">
<label for="inputPassword">Password</label> <input name='password'
type="password" id='inputPassword' ng-model='password'
class="form-control" placeholder="Enter Password" ng-minlength="6" ng-maxlength="30" required>
<input type="password" class="form-control" name='confirm_password'
placeholder="Re-enter Password" ui-validate="'$value==password'"
ui-validate-watch="'password'">
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Create
Account</button>
</form>
</div>
链接到angular-ui-validate https://github.com/angular-ui/ui-validate/blob/master/dist/validate.min.js
链接到我看到的示例: angularjs第三示例下的password-check指令
似乎很容易,但是!form.confirm_password。$ error.validator始终为true,没有例外
实际发生的事情很少...首先,我很愚蠢,忘记了将ui-validate放在我的模型依赖中...
然后我需要将一个ng-model添加到confirm_password字段中...
最后,我需要在表单中添加名称表单。
然后工作了...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.