I am using the following function and it works perfectly in chrome, returns true if there are no duplicates, returns false if there are duplicates and shows the #error div.
If I run it in IE11 it flags them all as duplicates and shows the #error div even though there aren't any duplicates...
// Check for duplicates
function checkSelect() {
var valid = true;
var atLeastAValue = false;
$("select").css("background-color", "white");
$.each($("select"), function (index, value) {
var others = $("select");
if ($(value.selectedOptions).val() !== "") {
$.each(others, function (otherIndex, otherValue) {
if ($(otherValue.selectedOptions).val() !== "") {
if (index === otherIndex && $(value.selectedOptions).val() === $(otherValue.selectedOptions).val()) {
atLeastAValue = true;
} else if ($(value.selectedOptions).val() === $(otherValue.selectedOptions).val()) {
$(value).css("background-color", "#ff9696");
$(otherValue).css("background-color", "#ff9696");
valid = false;
}
}
});
} else if (!atLeastAValue) {
$(value).css("background-color", "#ff9696");
valid = false;
}
});
if (!valid) {
var $div2 = $("#error");
if ($div2.is(":visible")) { return; }
$div2.show("slow");
setTimeout(function() {
$div2.hide("slow");
}, 10000);
}
return valid;
};
What is making this incompatible with IE11 and how can I make it compatible...
selected="selected"