0

I'm no professional and after research, I wasn't able to find a solution. I have a JavaScript source code for a SharePoint list to implement the InstantListFilter (https://archive.codeplex.com/?p=instantlistfilter) which works!

But I would like to update the source code so that the filter is NOT case sensitive. I was able to replace the the filter word (val) to uppercase (val = val.toUpperCase()). But I have no idea how to get the list-text to uppercase.

$("table.ms-listviewtable").children("tbody").each(function() {
  $(this).children("tr").each(function() {

    var mismatch = false;

    $(this).children("td").each(function(colIndex) {
      if (mismatch) return;

      if (filterValues[colIndex]) {
        var val = filterValues[colIndex];

        // replace double quote character with 2 instances of itself
        val = val.replace(/"/g, String.fromCharCode(34) + String.fromCharCode(34));

        val = val.toUpperCase(); //my adaption, working for the filter word
        $(this).val = $(this).val().toUpperCase(); //not working for the list-text

        // verifies the filter word.
        if ($(this).is(":not(:contains('" + val + "'))")) {
          mismatch = true;
        }
      }
    });

    if (mismatch) {
      $(this).hide();
    } else {
      $(this).show();
    }
  });

});

Does anybody have a solution? Would be happy with a short reply!

Roy Scheffers
  • 3,832
  • 11
  • 31
  • 36
Poldi
  • 1
  • 1
  • 1
    Try `$(this).val($(this).val().toUpperCase());` – Rocks Feb 28 '18 at 10:04
  • Possible duplicate of [Is there a case insensitive jQuery :contains selector?](https://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector) – Ele Feb 28 '18 at 10:07
  • `$(this).text()= $(this).text().toUpperCase()` – 4b0 Feb 28 '18 at 10:33

2 Answers2

0

The solution you are trying will also modify the input value to upper case, i'm not sure you want that? Maybe you could assign the input value to a var and see if it contains the text with String.indexOf()

...
val = val.toUpperCase(); //my adaption, working for the filter word
var inputVal = $(this).val().toUpperCase();

// indexOf = -1 means that inputVal does not contain val
if (inputVal.indexOf(val) === -1) {
  mismatch = true;
}
...
4b0
  • 21,981
  • 30
  • 95
  • 142
lofihelsinki
  • 2,491
  • 2
  • 23
  • 35
0

thanks for reply!!!

I got it:

var inputVal = $(this).text().toUpperCase();
//alert(inputVal);

// verifies the filter word.
// indexOf = -1 means that inputVal does not contain val
if (inputVal.indexOf(val.toUpperCase()) === -1) {
    mismatch = true;
}
Poldi
  • 1
  • 1