How to prevent select2 from accepting user input as one of the tag sentences

Implemented by Select2 in my project. Using the tag function provided in the plugin. The function works as indicated in the documentation, however I am stuck at some point.

I initialized the tag as follows:

HTML

<div class="form-group">
       <label for="languages">Languages <span class="mandatory">*</span> :</label>
       <input type="text" required="" placeholder="Languages" name="languages" id="languages" class="form-control">
</div>

JS:

$('#languages').select2({
     tags: languagenames,
});

Lanugagenames data:

[{"id":"1","text":"Afrikaans"},{"id":"2","text":"Albanian"},{"id":"3","text":"Arabic",....}]

, ( ). , "En", . , "En" . - , . , ?

enter image description here

+4
2

, .

- :

$('#languages').select2({
     tags: languagenames,
     createSearchChoice : function(term){
        return false;
    }
});
+4

, .

, tags: true false. .

$(".js-example-tokenizer").select2({
  tags: true,
  tokenSeparators: [',', ' ']
})
+1

All Articles