I am trying to make the search case insensitive, and I have tried all the solutions that are found in issues, but it's still not working. Here is the code that I have right now, but I want it to be able to search regardless if user types in letters with uppercase or lowercase.
loadData: function (filter) {
criteria = filter;
var data = $.Deferred();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "/Admin/getMultiCentreDeals",
dataType: "json"
}).done(function (response) {
var res = [];
if (criteria.dealTitle !== "") {
response.forEach(function (element) {
if (element.dealTitle.indexOf(criteria.dealTitle) > -1) {
res.push(element);
response = res;
}
}, this);
}
else res = response;
if (criteria.dealSubTitle !== "") {
res = [];
response.forEach(function (element) {
if (element.dealSubTitle.indexOf(criteria.dealSubTitle) > -1)
res.push(element);
}, this);
}
else res = response;
if (criteria.dealURL !== "") {
res = [];
response.forEach(function (element) {
if (element.dealURL.indexOf(criteria.dealURL) > -1)
res.push(element);
}, this);
}
else res = response;
data.resolve(res);
});
return data.promise();
},
},
var res = [];
if (criteria.HotelName !== "") {
response.forEach(function (element) {
if (element.HotelName.toLowerCase().indexOf(criteria.HotelName.toLowerCase()) > -1) {
res.push(element);
response = res;
}
}, this);
}
else res = response;