Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Required on a ngTagsInput doesn't work

I am using the ngTagsInput library in my app. Setting the required keyword is not affecting form validation. Why may this be the case?

<tags-input name="tags" min-length="2" add-on-paste="true" class="bootstrap" ng-model="name" id="name" placeholder="Name" required></tags-input>
like image 559
pratnala Avatar asked Dec 29 '25 09:12

pratnala


1 Answers

The required directive probably only works on regular text inputs. Instead, you can use the minTags attribute of ngTagsInput:

<form name="myForm">
    <tags-input name="tags" min-tags="1"></tags-input>
    <p ng-show="myForm.tags.$error.minTags">Tag required</p>
</form>

Then you can use the minTags validation error key instead of required error key to know if the user has entered at least one tag.

like image 73
Sunil D. Avatar answered Dec 31 '25 00:12

Sunil D.