0

I am creating a form and trying to put in following password validation:

Minimum 8, at least 1 Uppercase Alphabet, 1 Lowercase Alphabet, 1 Number and 1 Special Character:

Using the following regrex:

"/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]{8,}/"

Code:

Password:<input type="text" name="pass" ng-model="password" ng-pattern="/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.{8,}$)(?=.*[$@$!%*?&])[A-Za-z\d$@$!%*?&]/" required />
<span style="color:Red" ng-show="personForm.pass.$error.required"> Required! </span>
<span style="color:Red" ng-show="personForm.pass.$dirty&&personForm.pass.$error.pattern">Please Enter Valid Pass</span>

Now, what I want to do is display dynamic message to the user as he fills the password. E.g. if he has filled the uppercase, lowecase , special character but has not filled the number, I want to display that "Password should contain number". Is it possible without clicking on submit? Or should I do it at the click of button instead?

akshay
  • 61
  • 6

2 Answers2

0

I don't think you can do in this way, give a small message of your password combination and put submit button in the disabled state till your password is not valid.

RAj
  • 71
  • 2
  • 7
0

The correct answer is to use ngMessages. See here (since version 1.3, which I've realised might be too new for this post).

Sean
  • 1,151
  • 3
  • 15
  • 37