密码确认字段在angularjs

时间:2016-09-01 11:19:59

标签: php angularjs

                                            

                                            <div class="form-group">
                                                <label class="control-label control-label-1">Password</label>
                                                <input type="password" placeholder="Password" name="password" class="form-control form-control-1" ng-model="Userdata.password" required="">

                                            </div>

                                        </div>

                                        <div class="col-xs-6">  

                                            <div class="form-group"> 
                                                <label class="control-label control-label-1">Retype Password</label>
                                                <input type="password" placeholder="Retype Password" name="password2" class="form-control form-control-1" ng-model="Userdata.password2" required="">
                                               <div ng-show="Userdata.password != Userdata.password2">Password mis match!</div>

                                            </div>  

                                        </div>   

密码和密码确认字段工作不正常,在输入确认字段之前显示错误消息,即密码字段进入自身时。 我该如何正确地编写代码。

1 个答案:

答案 0 :(得分:2)

在ng-show中添加AND条件,

<div ng-show="(Userdata.password && Userdata.password2 && (Userdata.password != Userdata.password2))">Password mis match!</div>