Constraining Tag Creation
Use customTagCheck
option via JavaScript or data-custom-tag-check
via attribute to add some logic to the select field to return a Boolean
if an invalid value is entered. You can use the name of a function to set the option or a callback function.
Possible options to search for are: Banana, Apple, Orange, Lemon, Pepper, Mushrooms, Cabbages, Celery, Brocoli, Garlic
<div class="container">
<select id="my-select" multiple="multiple">
<option value="Apple" selected="selected">Apple</option>
</select>
</div>
function checkTag(input) {
return new Promise(function (resolve, reject) {
let ret = true;
if (input === "" || input.toLowerCase().includes("ä") || input.toLowerCase().includes("ö") || input.toLowerCase().includes("ü")) {
ret = false;
}
setTimeout(() => resolve(ret), 5000);
});
}
let select = new betterNiceSelect.BetterNiceSelect("#my-select", {customTagCheck: 'checkTag', tags: true});