【发布时间】:2017-07-14 22:23:09
【问题描述】:
所以我有一个密码并确认密码,如果不匹配,我显然需要匹配并显示一条消息。
我的要求:
- 该消息应仅在确认密码(第二次输入)输入后显示。
我现在的设置是,当用户模糊确认密码(第二次输入)时,函数运行并在不匹配时抛出错误消息,并且当用户键入与密码输入(第一次输入)匹配的正确密码(使用 onkeyup)时动态隐藏)
问题: 如果用户返回并更改第一个输入,则不会显示任何消息。如果我在密码(第一次输入)上使用相同的 onblur 功能,则在我在第二个字段中输入任何内容之前显示该消息(确认密码)。我该如何解决这个问题?
$onInit = () => {
let self = this;
this.siRole.getRoles().then((roleList) => {
self.roleList = roleList.filter((r) => {return !r.hidden});
}, (err) => {
self.siAlertDialog.error(err.message);
})
this.hide = true;
}
passwordWatchOnblur = ()=>{
this.hide = this.newUser.password == this.newUser.confirmPassword ? true :false
}
passwordWatchOnkeyup = ()=>{
if(this.newUser.password == this.newUser.confirmPassword){
this.hide=true;
}
}
<div layout layout-xs='column'>
<md-input-container flex class="md-accent">
<label translate="LABELS.PASSWORD"></label>
<input ng-model='$ctrl.newUser.password' type='password' required/>
</md-input-container>
<md-input-container flex class="md-accent">
<label translate="LABELS.CONFPASS"></label>
<input id="confirm" ng-model='$ctrl.newUser.confirmPassword' type='password' ng-blur="$ctrl.passwordWatchOnblur()" ng-keyup="$ctrl.passwordWatchOnkeyup()" required/>
<span ng-hide="$ctrl.hide" class='label-error'>{{'SI-MESSAGES.PASS-NO-MATCH'|translate}}</span>
</md-input-container>
</div>
【问题讨论】:
-
你可以试试这个指令:password-check directive in angularjs
标签: javascript html css angularjs