IE中的单选按钮执行更改功能,但不显示为已检查的jquery

时间:2012-07-09 18:43:15

标签: javascript jquery internet-explorer

我根据是否检查某些内容添加/删除类,并且它在firefox中运行正常,但IE不会显示复选框的值。触发更改/单击事件,但单选按钮实际上不显示选择,这会导致验证失败。知道发生了什么吗?

以下是更改css的js函数的代码:

function CheckHandlingUnit() {
    var flag = true;

    //Material Number
    if ($("#ContentPlaceHolder2_MatNum_TB").val() == "") {
        $("#ContentPlaceHolder2_MatNum_TB").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_MatNum_TB").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_MatNum_TB").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_MatNum_TB").removeClass("TBDecoRed");
    }

    //Description
    if ($("#ContentPlaceHolder2_Des_TB").val() == "") {
        $("#ContentPlaceHolder2_Des_TB").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_Des_TB").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_Des_TB").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_Des_TB").removeClass("TBDecoRed");
    }

    //Material Type
    if ($("#ContentPlaceHolder2_MatType_DD").val() == "1") {
        $("#ContentPlaceHolder2_MatType_DD").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_MatType_DD").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_MatType_DD").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_MatType_DD").removeClass("TBDecoRed");
    }

    //Inventory Classification
    if ($("#ContentPlaceHolder2_Inv_DD").val() == "1") {
        $("#ContentPlaceHolder2_Inv_DD").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_Inv_DD").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_Inv_DD").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_Inv_DD").removeClass("TBDecoRed");
    }

    //Shelf Life
    if ($("#ContentPlaceHolder2_SLife_TB").val() == "" && !$("#ContentPlaceHolder2_Unlimit_CB").is(":checked")) {
        $("#ContentPlaceHolder2_SLife_TB").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_SLife_TB").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_SLife_TB").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_SLife_TB").removeClass("TBDecoRed");
    }

    //Charge Number
    if ($("#ContentPlaceHolder2_Charge_TB").val() == "") {
        $("#ContentPlaceHolder2_Charge_TB").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_Charge_TB").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_Charge_TB").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_Charge_TB").removeClass("TBDecoRed");
    }

    //Quantity
    if ($("#ContentPlaceHolder2_Quan_TB").val() == "") {
        $("#ContentPlaceHolder2_Quan_TB").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_Quan_TB").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_Quan_TB").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_Quan_TB").removeClass("TBDecoRed");
    }

    //Serialized Radio Button
    if (!($("#ContentPlaceHolder2_Seri_RB_0").is(':checked')) &&
    !($("#ContentPlaceHolder2_Seri_RB_1").is(':checked'))) {
        $("#seriVal").show();
        flag = false;
    }
    else {
        $("#seriVal").hide();
    }

    //Moisture Sensitive Radio Button
    if (!($("#ContentPlaceHolder2_Moist_RB_0").is(':checked')) &&
    !($("#ContentPlaceHolder2_Moist_RB_1").is(':checked'))) {
        $("#moistureVal").show();
        flag = false;
    }
    else {
        $("#moistureVal").hide();
    }

    //Hazardous Radio Button
    if (!($("#ContentPlaceHolder2_Haz_RB_0").is(':checked')) &&
    !($("#ContentPlaceHolder2_Haz_RB_1").is(':checked'))) {
        $("#hazardVal").show();
        flag = false;
    }
    else {
        $("#hazardVal").hide();
    }

    //Packaging Requirement
    if (!$("#ContentPlaceHolder2_PackingReq_CBL_0").is(':checked') &&
    !$("#ContentPlaceHolder2_PackingReq_CBL_1").is(':checked') &&
    !$("#ContentPlaceHolder2_PackingReq_CBL_2").is(':checked') &&
    !$("#ContentPlaceHolder2_PackingReq_CBL_3").is(':checked') &&
    !$("#ContentPlaceHolder2_PackingReq_CBL_4").is(':checked'))
    {
        $("#packageVal").show();
        flag = false;
    }
    else{
        $("#packageVal").hide();
    }

    //package Other
    if ($("#ContentPlaceHolder2_PackingReq_CBL_2").is(':checked') && $("#ContentPlaceHolder2_OtherPkgRequirent_TB").val() == "") {
        $("#ContentPlaceHolder2_OtherPkgRequirent_TB").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_OtherPkgRequirent_TB").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_OtherPkgRequirent_TB").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_OtherPkgRequirent_TB").removeClass("TBDecoRed");
    }

    //Hazardous Material
    if ($("#ContentPlaceHolder2_Haz_RB_0").is(':checked') && $("#ContentPlaceHolder2_MSDS_TB").val() == "") {
        $("#ContentPlaceHolder2_MSDS_TB").addClass("TBDecoRed");
        $("#ContentPlaceHolder2_MSDS_TB").removeClass("TBDecoNone");
        flag = false;
    }
    else {
        $("#ContentPlaceHolder2_MSDS_TB").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_MSDS_TB").removeClass("TBDecoRed");
    }
    //File upload
    if ($("#ContentPlaceHolder2_Haz_RB_0").is(':checked') && $("#ContentPlaceHolder2_MSDSFileUpload").val() == "") {
        flag = false;
        $("#ContentPlaceHolder2_MSDSFileUpload").addClass("FileUploadRed");
        $("#ContentPlaceHolder2_MSDSFileUpload").removeClass("TBDecoNone");
    }
    else {
        $("#ContentPlaceHolder2_MSDSFileUpload").addClass("TBDecoNone");
        $("#ContentPlaceHolder2_MSDSFileUpload").removeClass("FileUploadRed");
    }

    return flag;
}

0 个答案:

没有答案