All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.textAngular.src.validators.js Maven / Gradle / Ivy

angular.module('textAngular.validators', [])
    .directive('taMaxText', function () {
        return {
            restrict: 'A',
            require: 'ngModel',
            link: function (scope, elem, attrs, ctrl) {
                var max = parseInt(scope.$eval(attrs.taMaxText));
                if (isNaN(max)) {
                    throw('Max text must be an integer');
                }
                attrs.$observe('taMaxText', function (value) {
                    max = parseInt(value);
                    if (isNaN(max)) {
                        throw('Max text must be an integer');
                    }
                    if (ctrl.$dirty) {
                        ctrl.$validate();
                    }
                });
                ctrl.$validators.taMaxText = function (viewValue) {
                    var source = angular.element('
'); source.html(viewValue); return source.text().length <= max; }; } }; }).directive('taMinText', function () { return { restrict: 'A', require: 'ngModel', link: function (scope, elem, attrs, ctrl) { var min = parseInt(scope.$eval(attrs.taMinText)); if (isNaN(min)) { throw('Min text must be an integer'); } attrs.$observe('taMinText', function (value) { min = parseInt(value); if (isNaN(min)) { throw('Min text must be an integer'); } if (ctrl.$dirty) { ctrl.$validate(); } }); ctrl.$validators.taMinText = function (viewValue) { var source = angular.element('
'); source.html(viewValue); return !source.text().length || source.text().length >= min; }; } }; });




© 2015 - 2025 Weber Informatics LLC | Privacy Policy