首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >角JS确认密码消息已经显示

问角JS确认密码消息已经显示
EN

Stack Overflow用户
提问于 2016-11-17 08:18:30
回答 1查看 95关注 0票数 1

我有两个字段密码和确认密码以及标签中的错误消息,即“密码不匹配”,但是当密码输入错误时,应该在“确认密码”字段中显示,而当我打开表单时,它已经在显示了。

HTML

代码语言:javascript
复制
<div class="form-group" ng-class="{ 'has-error': submitted && CreateClientAdminForm.password.$error.required || CreateClientAdminForm.password.$error.pattern }" >
                <label class="col-md-4 control-label" for="password">Password*</label>
                <div class="col-md-4">
                    <input id="password" name="password" type="password" placeholder="Password" class="form-control input-md" ng-model="clientAdmin.User.UserPassword"  ng-pattern="regex.Password" ng-maxlength="20" required  autofocus>
                    <span ng-show="submitted && CreateClientAdminForm.password.$error.required" class="help-block">Password can not be empty</span>

                    <span ng-show="CreateClientAdminForm.password.$error.pattern && CreateClientAdminForm.password.$invalid " class="help-block">Please enter a valid password with at least 6 characters. </span>
                </div>
            </div>
            <!-- Password input-->
            <div class="form-group" ng-class="{ 'has-error': submitted && CreateClientAdminForm.confirmpassword.$error.required || CreateClientAdminForm.confirmpassword.$error.pattern }" >
                <label class="col-md-4 control-label" for="confirmpassword">Confirm Password*</label>
                <div class="col-md-4">
                    <input id="confirmpassword" name="confirmpassword" type="password" placeholder="Password" class="form-control input-md" ng-model="clientAdmin.User.UserconfirmPassword"  ng-pattern="regex.Password" ng-maxlength="20" required  autofocus>
                    <span ng-show="submitted && CreateClientAdminForm.confirmpassword.$error.required" class="help-block">Password can not be empty</span>
                    <span ng-show="clientAdmin.User.UserPassword !== clientAdmin.User.UserconfirmPassword" class="help-block"><p>Password mismatch</p></span>

                    <span ng-show="CreateClientAdminForm.confirmpassword.$error.pattern && CreateClientAdminForm.confirmpassword.$invalid " class="help-block">Please enter a valid password with at least 6 characters. </span>
                </div>
            </div>

控制器

代码语言:javascript
复制
    globalWeAlertApp.controller("ClientAdminController", function($scope, ClientAdminService,UserCRUDService, toastr, $cookieStore, $window ) {

              //Other functions

    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-17 09:20:55

代码语言:javascript
复制
<span
ng-show="clientAdmin.User.UserPassword != clientAdmin.User.UserconfirmPassword
&& (clientAdmin.User.UserPassword != '' &&
lientAdmin.User.UserconfirmPassword != '' )" 
class="help-block">
<p>Password mismatch</p>
</span>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40649773

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档