我在Angular.js.中使用ngCapsLock
模块时遇到问题。我只需要在密码提交时对消息进行封锁,但是当我在我的表单的任何其他字段而不是密码字段中按下capslock时,消息也是显示。请检查我的代码。
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Email Id :</span>
<div ng-class="{ 'has-error': billdata.email.$touched && billdata.email.$invalid }">
<input type="email" name="email" id="contactno" class="form-control" placeholder="User email" ng-model="user_email" ng-pattern="/^[_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$/" >
</div>
</div>
<div class="help-block" ng-messages="billdata.email.$error" ng-if="billdata.email.$touched">
p ng-message="email" style="color:#F00;">This needs to be a valid email</p>
<p ng-message="pattern" style="color:#F00;">This field needs valid email format(e.g-abc@gmail.com).</p>
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Password :</span>
<div ng-class="{ 'has-error': billdata.pass.$touched && billdata.pass.$invalid }">
<input type="password " name="pass" id="contactno" class="form-control" placeholder="password" ng-model="password" ng-minlength="8" ng-pattern="/^(?=.*[A-Z])(?=.*\d)(?=.*[a-z]).*_.*/" >
</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 and underscore.</p>
<p class="caps-lock-alert" ng-show='isCapsLockOn' style="color:#F00;">Capslock is on</p>
</div>
这里我的要求是当用户只在密码字段中进行大写锁定消息将来。但是这里有许多其他字段,如电子邮件,用户名等。我的问题是当用户正在进行大写锁定时在任何其他字段而不是密码字段中,消息也会出现,不应该显示。我已经包含了ngCapsLock
。请帮助我。