Item Creation Examples
new TomSelect('#select-words-regex',{
create: true,
createFilter: document.getElementById('regex').value,
});
<select id="select-words-regex" multiple placeholder="Enter a word matching the pattern..."></select>
<div class="control-group form-inline">
<label for="regex" class="me-2">Pattern</label>
<input type="text" id="regex" value="^a+$" class="form-control">
</div>
new TomSelect('#select-words-length',{
create: true,
createFilter: function(input) { return input.length >= parseInt( document.getElementById('length').value, 10); }
});
<select id="select-words-length" multiple placeholder="Enter a word longer than the minimum number of characters..."></select>
<div class="control-group form-inline">
<label for="length" class="me-2">Minimum length</label>
<input id="length" value="2" class="form-control" />
</div>
var unique = new TomSelect('#select-words-unique',{
create: true,
createFilter: function(input) {
input = input.toLowerCase();
return !(input in this.options);
}
});
<select id="select-words-unique" multiple placeholder="Enter unique words (case-insensitive)..."></select>