Constraining Tag Creation


Use tagsCheck option via JavaScript or data-tags-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.

<div class="container">
    <select id="my-select" multiple="multiple">
        <option value="Apple" selected="selected">Apple</option>
    </select>
</div>

function checkTag(key) {
    if (key.toLowerCase().includes("ä") || key.toLowerCase().includes("ö") || key.toLowerCase().includes("ü")) {
        return false;
    }
    return true;
}

let select = bootstrapNiceSelect.BootstrapNiceSelect("#my-select", {tagsCheck: 'checkTag', tags: true});