2
Setting:
I have a form with 3 steps, a jsp for each step. In a given jsp there is a input
text
with the directiveng-minlength
and aonChange
calling a function that validates with the$setValidity
if the given value is invalid.Problem:
When the field is invalid and the navigation occurs between the steps, when returning to the stage the field loses the invalid status. As a solution, I tried to validate the field when loading the page but error occurs when executing the code below because the form has not been loaded yet:
$scope.form.numeroCartao.$setValidity("valid", true);
Question:
How to validate a field with the
$setValidity
when loading the page?
Hello Victor, I started calling my function in ng-init right in the form, but it still can’t locate the name of the form I want to invalidate according to the code:
$scope.form.numeroCartao.$setValidity("valid", false);
.– Eduardo Nobre
TypeError: Não é possível obter a propriedade 'numeroCartao' de referência indefinida ou nula
– Eduardo Nobre
The card number has not yet been loaded, inside the form.
– Eduardo Nobre
Dude, put your HTML in a Gist or Jsfiddle so we have a better idea of what you’re doing.
– Victor Högemann