2

Good Morning Friends;

I am using a JQuery script to act as a filter on a custom list. The text in my custom list is all Uppercase. Currently the filter is case sensitive. I tried using text-transform to uppercase, which indeed transforms the text in the box. However, the filter still will not work unless CAPS Lock is on, on my keyboard.

Any help would be appreciated.

<SCRIPT type="text/javascript"src="SiteAssets/Scripts/jquery.min.js"></SCRIPT>

<SCRIPT type=text/javascript>

jQuery(document).ready(function($){
    //attach a function to the keyup event on the filter box
    $('#filterInput').keyup(function() 
    {
        var inputVal = $('#filterInput').val():
        DynamicFilter(inputVal.toUpperCase());
    });
})

//strip off html taqs
function stripHTML (field) {
    return field.replace(/<([^>]+)>/g,'');
}

function DynamicFilter(text)
{
    //find out list view (default class for a listview is "ms-listviewtable"
    $('table [class="ms-listviewtable"]').find('tr').each(function()
        {
            //don't filter out the header row
            if ($(this).attr("class") != "ms-viewheadertr ms-vhltr")
            {
                //get the html for the row and strip off the html tabs
                source = stripHTML($(this).html());

                //check to see if the filter text exists in the remaining text
                if (source.indexOf(text) < 0)
                {
                    //hide the row if it doesn't contain the text
                    $(this).hide();
                } else {
                    //otherwise show it
                    $(this).show();
                }
            }
        }
    );
}

</script>

<div id="mainDiv">
    <table>
        <tr>
            <td class='Filter' width='125px'>Search: <input type="Text" id="filterInput" ></td>
        </tr>
    </table>
</div>
2

Try using below code. It should work in your case:

$('#filterInput').keyup(function() 
{ 
    var inputVal = $('#filterInput').val():
    DynamicFilter(inputVal.toUpperCase());
}); 
  • Should I keep the Text Transform action? – Daryl Jan 27 at 16:04
  • When I add this to the original code, the filter does not work. Unless I added it wrong? – Daryl Jan 27 at 16:12
  • You don't need text transform in this case.try adding without using transform. – Ganesh Sanap Jan 27 at 17:35
  • Can you add it to the original code? I'm worried I'm not doing it right as it does not work. – Daryl Jan 27 at 17:49
  • I updated the code sample on the main post, with what I am using with your suggestion. – Daryl Jan 27 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.