gpt4 book ai didi

javascript - 检查密码匹配时出错

转载 作者:行者123 更新时间:2023-11-28 06:10:00 25 4
gpt4 key购买 nike

我无法检查密码是否与确认密码匹配。

这是用户输入密码的模态形式

<div class="form-group has-feedback" ng-class="addUser.password.$valid ? 'has-success' : 'has-error';" ng-hide="hideField">
<label class="control-label" for="password">Password</label>
<input type="password" class="form-control" name="password" ng-model="user.password" required ng-minlength="8">
<span class="glyphicon form-control-feedback" ng-class="addUser.password.$valid ? 'glyphicon-ok' : 'glyphicon-remove';"></span>
</div>

<div class="form-group has-feedback" ng-class="addUser.confirmpassword.$valid ? 'has-success' : 'has-error';" ng-hide="hideField">
<label class="control-label" for="confirmpassword">Re-enter Password</label>
<input type="password" class="form-control" name="confirmpassword" ng-model="user.confirmpassword" required ng-minlength="8" >
<span class="glyphicon form-control-feedback" ng-class="addUser.confirmpassword.$valid ? 'glyphicon-ok' : 'glyphicon-remove';"></span>
</div>

这是提交按钮

<button type="submit" class="btn btn-primary btn-block" ng-disabled="!allowSubmit(addUser)" ng-click="add();">Save</button>

我想要的是,在提交表单之前,用户输入的密码必须与确认密码匹配。我正在做这样的事情。但它并没有按照我的意愿检查密码。感谢您的帮助。

$dialogScope.add = function() {

if ($dialogScope.user.password != $dialogScope.user.confirmpassword)
{
dialogScope.errorMessage = "Password does not match!"
}

最佳答案

在父表单上使用 ng-submit="add()" 并从提交按钮中删除 ng-click="add();"

$dialogScope.add = function() {
if ($dialogScope.user.password != $dialogScope.user.confirmpassword) {
dialogScope.errorMessage = "Password does not match!";
return false;
}

// Do what you want to do after for form submission
};

关于javascript - 检查密码匹配时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36493624/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com