mpop
mpop

Reputation: 499

In IE with compatibility mode JQuery .val() not working

I have been tasked with fixing a "but" on a web app. The issue is that I have found that when I call .val() in jQuery on a text field that is set as a type search, it returns nothing.

The code is

$('input[type=search],select').each(function(){
    console.log("looking at " + $(this).val() + ":"+defaultValue+ ":"+areDatesValid+":"$(this)); 
    //Will only enable Search Button atleast one field has data and the datefields are of correct format or empty
    if ( $(this).val() !="" && $(this).val() !=defaultValue && areDatesValid == true)
    {
        divClassWithInputVal = $(this).attr("class");   
        $("input[id=enabledSection]").val(divClassWithInputVal);
        $('#searchButton').removeAttr("disabled");  
    }
});

It is working properly in Web Kit (Chrome, Edge) and in IE11, but it does not work in IE7 (and to those that say why fix it in IE7, I would love to ignore that as IE7 is so old and should be put out to pasture, but since customers are complaining that it does not work for them, I am stuck with fixing it)

console.log was added to figure out what was going on, and in IE7 mode the $(this).val() always returns nothing. jQuery version is 1.6.1

I am unable to find any information, most of my searches returns results from 9+ years ago (not surprised there)

Upvotes: 0

Views: 274

Answers (0)

Related Questions