Password matching in AngularJS using the $validators pipeline produces unexpected results -
see illustration here.
using $validators pipeline, trying check field contains same value field.
each input in illustration associated other, such expected result follows:
enter value in input#1 enter same value in input#2 both fields should valid alter value in input#1 input#1 should invalid (or input#2 or both)initially, did using $watch
on both current model , target equal to, 1 of 2 fields needed utilize directive. however, introduction of $validators
pipeline, method stopped working unexpectedly (maybe bug).
anyhow, can see, when sec input altered, value receives associated input undefined
.
i solved following:
jsfiddle
as nikos said, 2 instances cancelling each other out, fixed next code:
$scope.$watch('passwordwatch', function(pass) { $control.$validate(); });
so now, when target input changes, current input revalidates. when current input changes, validates automatically (as usual).
one problem when validator fails (returns false
), underlying model value set undefined
. so:
"aaa"
; not same passwordconfirm
, validator returns false
, model gets undefined
value you type same value in passwordconfirm; above value of password undefined
, undefined !== "aaa"
, passwordconfirm validator returns false
too. and on... angularjs angularjs-directive
No comments:
Post a Comment