In JQuery autocomplete , similar items with difference of multiple spaces in between words are shown as duplicates item in drop-down as Jquery plugin itself is trimming the drop-down items.
Demo:Working demo of issue
var validOptions =["Item 1", "Item 1", "Item 1", "Item 2", "Item 2"];
previousValue = "";
$('#ac').autocomplete({
autoFocus: true,
source: validOptions,
}).keyup(function() {
var isValid = false;
for (i in validOptions) {
if (validOptions[i].toLowerCase().match(this.value.toLowerCase())) {
isValid = true;
}
}
if (!isValid) {
this.value = previousValue
} else {
previousValue = this.value;
}
});
Is there any way to show the value as such in drop-down items.