I try to set an input as required if another input has changed. My need is to require confirm password if password has changed.
I use this on the input of confirm password but it is never required :
ng-required="userForm.Password.$touched"
Another question : Is there a way to remove ng-Model="user.ConfirmPassword"
? because ConfirmPassword is not necessary on my model "user", isn't it?
You should use the name
property instead of id
.
Also, this is no valid syntax:
<span class="error" ng-show="userForm.Password.$touched userForm.Password.$error.required">Password is required</span>
It should be:
<span class="error" ng-show="userForm.Password.$touched">Password is required</span>
Then it will work just fine, as long as Password
is the name of the input element, not the ID.