typeahead bootstrap 4 add multiple values
To add multiple values in Bootstrap 4 typeahead, you can use the multiple
attribute along with the tags
option. This allows users to enter multiple values separated by a specified delimiter.
Here's an example of how you can achieve this:
<input type="text" class="form-control" id="myTypeahead" data-provide="typeahead" multiple>
In your JavaScript code, you need to initialize the typeahead component and set the tags
option to true:
$(document).ready(function() {
$('#myTypeahead').tagsinput({
tags: true
});
});
With this setup, users can enter multiple values into the input field, separated by a default delimiter (which is usually a comma).
Keep in mind that to use typeahead in Bootstrap 4, you need to include the necessary JavaScript and CSS files. You can download them from the official Bootstrap website or use a CDN.
Note: The tagsinput
library mentioned in the JavaScript code is not a part of Bootstrap 4 by default. It is an additional library that provides enhanced functionality for handling multiple values in typeahead inputs.
I hope this helps! Let me know if you have any further questions.