You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have set up a 'plnker' to demonstrate a common issue when users fill in forms, that have values later on that are dependant on and validated by values put into previous inputs. Please see the following: https://plnkr.co/edit/ELplnBCAUjatpusW6EPU?p=preview
Enter some values - for example
10
Hello World
15
and you will get the warning AFTER the second Number of - 'A maximum value of 10 is allowed.'
If you now tab back UP the form or just click into the first input and enter a value of 100 instead and blur out of that control into the next one - then the value in form.value1 is updated. However the validation does not see the update and still continues to show an error messages - even hough its input is now actually valid (and its label and validator have both been updated) ....
How do you get the validation to fire again for the seconds input so that the error message goes away ... ?????
The text was updated successfully, but these errors were encountered:
codeuniquely
changed the title
Validations not updating when dependant on other form values
Validators not updating when dependant on other form values
Jul 4, 2017
There is already an $observe on the validator - which updates it and we could use this to re-run the validation rule after...
current code
/**
* Observe validator changes in order to allow dynamically change it
*/
attrs.$observe('validator', function(value) {
validation = value.split(',');
});
if this was updated to also make a call back to checkValidation then the error messages would automatically be removed once the conditions on the later validation have been met
Suggestion:
/**
* Observe validator changes in order to allow dynamically change it
*/
attrs.$observe('validator', function(value) {
validation = value.split(',');
// validation has been updated => make the validation fire again
var theValue = useViewValue ? ctrl.$viewValue : ctrl.$modelValue;
checkValidation(scope, element, attrs, ctrl, validation, theValue);
});
I have set up a 'plnker' to demonstrate a common issue when users fill in forms, that have values later on that are dependant on and validated by values put into previous inputs. Please see the following:
https://plnkr.co/edit/ELplnBCAUjatpusW6EPU?p=preview
Enter some values - for example
and you will get the warning AFTER the second Number of - 'A maximum value of 10 is allowed.'
If you now tab back UP the form or just click into the first input and enter a value of 100 instead and blur out of that control into the next one - then the value in form.value1 is updated. However the validation does not see the update and still continues to show an error messages - even hough its input is now actually valid (and its label and validator have both been updated) ....
How do you get the validation to fire again for the seconds input so that the error message goes away ... ?????
The text was updated successfully, but these errors were encountered: