0

I am using jQuery-TokenInput in my application.I have some list of items, so when we enter any text if it is matched with the text in the list then it should not be added.

For example: If I had a list["abc","def","xyz"].

So if we enter in "xyz" in the jQuery-TokenInput textbox, it should not add.

Thanks,
Naresh.

Naresh.P
  • 399
  • 1
  • 3
  • 10

1 Answers1

1

I'd work with the onAdd event, and use the remove function call. Try something along these lines. (It will need debugging, but I think the principle should work.)

var list = ["abc","def","xyz"];

var newTI = $("#myTI").tokenInput("search.php", {
   propertyToSearch: "val",
   onAdd: function(item){
      if ($.inArray(list,item.val)) selector.tokenInput("remove", item);
   },
});
Chris
  • 5,882
  • 2
  • 32
  • 57