codeMan
codeMan

Reputation: 5758

How to I prevent user from typing the same tag in the Textext textarea

I am using Textext plugin for the tags. What am trying to achieve is to prevent multiple duplicates of the items(tags) typed in the textarea.

enter image description here

As you can see in the above pic the tag "C" is typed twice. It want to prevent the user from typing the duplicates. How do I do this?

I came across the filter plugin But its functionality is little different from what I want.

I am sure there is some good way to achieve this. Please help!

Upvotes: 1

Views: 789

Answers (1)

Mr_Green
Mr_Green

Reputation: 41832

Use the below to get the inside text:

var txt = document.getElementById('textarea');
var insideText = $(txt).parent().children('div').text();

The text will be in concatenated form. So, you need to take care when the user deletes the tag or creates a new tag.

To test the above code, run it in console tab of developer tool of the browser.

Upvotes: 1

Related Questions