For example I want to add custom validation where addedValue<20, how to implemenet it?
<tags-input ng-model="numbers"
placeholder="Add a number"
min-length="1"
max-length="3"
allowed-tags-pattern="^[0-9]+$"
onTagAdded="$tag<20"></tags-input>
this is code I use.
For example I want to add custom validation where addedValue<20, how to implemenet it?
<tags-input ng-model="numbers"
placeholder="Add a number"
min-length="1"
max-length="3"
allowed-tags-pattern="^[0-9]+$"
onTagAdded="$tag<20"></tags-input>
this is code I use.
Share edited May 6, 2015 at 12:32 Shekspir asked May 6, 2015 at 12:13 ShekspirShekspir 892 silver badges12 bronze badges1 Answer
Reset to default 8You could use the on-tag-adding
attribute to check if it's a valid tag:
<tags-input ng-model="numbers"
placeholder="Add a number"
min-length="1"
max-length="3"
on-tag-adding="checkTag($tag)">
</tags-input>
In your controller:
$scope.checkTag = function(tag) {
// check if its a valid number and smaller than 20
return !isNaN(tag.text) && +tag.text < 20;
}