角度js中的密码验证 [英] Password validation in angular js

查看:60
本文介绍了角度js中的密码验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

密码和确认密码不匹配但验证没有被触发



我尝试过:



< pre> 
< div class =form-groupng-class ={'has-error':registrationForm.pwd。$ invalid&&!registrationForm.pwd。$ pristine}>
< label for =pwd>密码:< / label>
< input type =passwordclass =form-controlid =pwdname =pwdplaceholder =Enter Passwordng-model =userdetails.pwdrequired />
< span style =color:redng-show =registrationForm.pwd。$ dirty&& registrationForm.pwd。$ invalid>
< span ng-show =registrationForm.pwd。$ error.required>密码是必需的。< / span>
< / span>
< / div>

< div class =form-groupng-class ={'has-error':registrationForm.conpwd。$ invalid&&!registrationForm.conpwd。$ pristine}> ;
< label for =pwd>确认密码:< / label>
< input type =passwordclass =form-controlid =conpwdname =conpwdplaceholder =Enter Confirm Passwordng-model =userdetails.conpwdng-match = userdetails.pwdrequired />
< span style =color:redng-show =registrationForm.conpwd。$ dirty&& registrationForm.conpwd。$ invalid>
< span ng-show =registrationForm.conpwd。$ error.required>密码是必需的。< / span>
< span ng-show =registrationForm.conpwd。$ error.match>密码不匹配..< / span>
< / span>
< / div>

解决方案

无效&& !registrationForm.pwd。


pristine}>
< label for =pwd>密码:< / label>
<输入类型=passwordclass =form-controlid =pwdname =pwdplaceholder =Enter Passwordng-model =userdetails.pwdrequired />
< span style = color:redng-show =registrationForm.pwd。


dirty&& registrationForm.pwd。

password and the confirm password does not match yet the validation is not being triggered

What I have tried:

<pre>
		<div class="form-group" ng-class="{ 'has-error' : registrationForm.pwd.$invalid && !registrationForm.pwd.$pristine}">
		<label for="pwd">Password:</label>
		<input type="password" class="form-control" id="pwd" name="pwd"  placeholder="Enter Password" ng-model="userdetails.pwd" required />
		<span style = "color:red" ng-show = "registrationForm.pwd.$dirty && registrationForm.pwd.$invalid"> 
		<span ng-show = "registrationForm.pwd.$error.required">Password is required.</span>  
		</span>	
		</div>
		
		<div class="form-group" ng-class="{ 'has-error' : registrationForm.conpwd.$invalid && !registrationForm.conpwd.$pristine}">
		<label for="pwd">Confirm Password:</label>
		<input type="password" class="form-control" id="conpwd" name="conpwd"  placeholder="Enter Confirm Password" ng-model="userdetails.conpwd" ng-match="userdetails.pwd" required />
		<span style = "color:red" ng-show = "registrationForm.conpwd.$dirty && registrationForm.conpwd.$invalid"> 
		<span ng-show = "registrationForm.conpwd.$error.required">Password is required.</span>  
<span ng-show = "registrationForm.conpwd.$error.match">Password do not match..</span> 
		</span>	
		</div>

解决方案

invalid && !registrationForm.pwd.


pristine}"> <label for="pwd">Password:</label> <input type="password" class="form-control" id="pwd" name="pwd" placeholder="Enter Password" ng-model="userdetails.pwd" required /> <span style = "color:red" ng-show = "registrationForm.pwd.


dirty && registrationForm.pwd.


这篇关于角度js中的密码验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆