← Examples

Whitelist mode

Only values from the suggestion list are accepted. Typing anything else and committing (Enter, comma, or Tab) triggers an error.

Try typing "Python" or "Rust" (valid) versus "COBOL" or "PHP" (not in list).

View code
<label for="tags">Programming languages</label>
<input id="tags" type="text" name="languages" />

<script type="module">
  import { Taga11y } from '../dist/taga11y.mjs';

  new Taga11y(document.getElementById('tags'), {
    suggestions: ['C', 'C++', 'Go', 'Java', 'JavaScript', 'Python', 'Rust', 'TypeScript'],
    enforceSuggestions: true,
  });
</script>