I'm trying to validate my password field with specific special characters requirements. The field must contain at least one number, upper case letter, lower case letter, and an underscore, all of which are mandatory. I have attempted to achieve this using ng-pattern
and ng-message
, but have been unsuccessful so far. Below is a snippet of my code:
<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="{{inputType}}" name="pass" id="contactno" class="form-control" placeholder="password" ng-model="password" ng-minlength="8" ng-pattern="/[a-zA-Z][0-9][a-zA-Z0-9]{3}/." >
</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 minimum length for the password should be 8 characters.</p>
<p ng-message="pattern" style="color:#F00;">This field requires special characters like numbers, uppercase letters, lowercase letters, and underscores.</p>
</div>
I am not receiving any error messages despite my efforts. Any assistance would be greatly appreciated.