tags:

views:

104

answers:

4

Title sums it up.

A: 

No. You will have to fiddle with your data, I usually make all my strings lowercase for easy comparisons. There is also the possibility of using a custom comparison function which would do the necessary transforms to make the comparison case insensitive.

adamse
+1  A: 

could loop through the array and toLower each element and toLower what you're looking for, but at that point in time, you may as well just compare it instead of using inArray()

Crayon Violent
+5  A: 

You can use each()...

// Iterate over an array of strings, select the first elements that 
// equalsIgnoreCase the 'matchString' value
var matchString = "MATCHME";
var rslt = null;
$.each(['foo', 'bar', 'matchme'], function(index, value) { 
  if (rslt == null && value.toLowerCase().equals(matchString.toLowerCase())) {
    rslt = index;
    return false;
  }
});
Drew Wills
You will want to add a "return false;" at the end of that if statement so the 'each' doesn't continue after a matching element is found. (In jQuery.each() "return false;" is equivalent to "break;" in a regular JavaScript loop.)
Jordan
Isn't it toLowerCase rather than toLower?
Sarfraz
@Jordan and @Sarfraz: both good points
Drew Wills
+1  A: 

Hi John,

It looks like you may have to implement your own solution to this. Here is a good article on adding custom functions to jQuery. You will just need to write a custom function to loop and normalize the the data then compare.

http://jquery-howto.blogspot.com/2008/12/how-to-add-your-own-custom-functions-to.html

Skyler