Javascript 使用angular.js验证密码失败

Javascript 使用angular.js验证密码失败,javascript,angularjs,validation,Javascript,Angularjs,Validation,我无法使用Angular.js正确验证密码字段。让我先解释一下我的代码 <span class="input-group-addon ndrftextwidth text-right" style="width:180px">Password :</span> <div ng-class="{ 'myError': billdata.pass.$touched && billdata.pass.$invalid }"> <input ty

我无法使用Angular.js正确验证密码字段。让我先解释一下我的代码

<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Password :</span>
<div ng-class="{ 'myError': billdata.pass.$touched && billdata.pass.$invalid }">
<input type="{{inputType}}" name="pass" id="deptpass" class="form-control" placeholder="password" ng-model="password" ng-minlength="8" ng-pattern="/^(?=.*[A-Z])(?=.*\d)(?=.*[a-z]).*_.*/" ng-keypress="clearField('deptpass');" >
 </div>
</div>
<div class="help-block" ng-messages="billdata.pass.$error" ng-if="billdata.pass.$touched">
<p ng-message="minlength" style="color:#F00;">This field is too short.The min length of your password should be 8.</p>
<p ng-message="pattern" style="color:#F00;">This field needs the special character like at least one number,upper case,lower case letter,_,@,#,&,%</p>
</div>

这里我得到的消息高达下划线。如果用户键入@、$、&%等字符(该字段也应使用该字符),则无法验证。请帮助我。

如果我在这里没有错,则您需要ng模式作为密码,该密码至少包含一个数字、大写字母、小写字母、@、&%,最小长度为8

请使用以下ng模式:

/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[_!@#\$%\^&\*])(?=.{8,})/

这只允许字符串至少包含一个数字,大写字母,小写字母,,@,&%,最小长度为8。

因此,您基本上要求我们调试正则表达式:/^?=.[A-Z]?=.*\d?=.[A-Z].*.*.*.*/Ok,我将添加这些缺少的字符。看起来您需要在密码中加下划线…?是的,但我还需要@、、$、%,&喜欢它的性格。