:selected does not work with datalist parameters, since a single data source can provide offers for several inputs. If two different inputs contain two different sentences from the list, which will be selected?
As mentioned in other comments, you can check the input value when changing as follows:
$("input[name='Typelist']").on('input', function(e){ var selected = $(this).val(); });
However, if you want to make sure that this value is actually one of the parameters from the datalist, you will need to do an additional check, as visitors to the datalist can still enter different values ββin the input. Datalist just offers suggestions.
Solution for checking if a value is in the data directory:
$("input[name='Typelist']").on('input', function(e){ var $input = $(this), val = $input.val(); list = $input.attr('list'), match = $('#'+list + ' option').filter(function() { return ($(this).val() === val); }); if(match.length > 0) {
source share