Password matching in AngularJS using the $validators pipeline produces unexpected results

前端 未结 1 666
囚心锁ツ
囚心锁ツ 2021-01-28 15:18

See the example here.

Using the $validators pipeline, I am trying to check that a field contains the same value as another field.

Each input in this example is a

1条回答
  •  抹茶落季
    2021-01-28 15:44

    One problem is that when a validator fails (returns false), then the underlying model value is set to undefined. So:

    1. You type something in the password, say "aaa"; this is NOT the same as passwordConfirm, so the validator returns false and the model gets the undefined value
    2. You type the same value in passwordConfirm; but from above the value of the password is undefined and undefined !== "aaa", so the passwordConfirm validator returns false too.
    3. And so on...

    0 讨论(0)
提交回复
热议问题