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
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Hi,
I am using ng-maxlength validation directive to validate input value for max length. but I need to change the value dynamically based on some rules defined. Currently, It's setting up the value outside the maxLengthValidator function scope So it's setting value on compile time. Could you please allow to change the maxvalue length dynamically by moving var maxlength = int(attr.ngMaxlength); inside the function ? or may some other solution. ngMinlength has got the same issue
Also, It clears the invalid value from the input textbox, is it desired behaviour ? because i do not wish to clear the text box value even if it is not valid length.
// max length validator
if (attr.ngMaxlength) {
var maxlength = int(attr.ngMaxlength);
var maxLengthValidator = function(value) {
if (!ctrl.$isEmpty(value) && value.length > maxlength) {
ctrl.$setValidity('maxlength', false);
return undefined;
} else {
ctrl.$setValidity('maxlength', true);
return value;
}
};