简体   繁体   中英

document.getElementById('rowtxtConsidAmt') null only in mozilla

I am gettig the above error in mozila, but its works well in IE

Javascript:

function ValidateForm() { 

    var objtxtStampDutyAmt= document.getElementById(contentPlaceholderId + 'txtStampDutyAmt');
     if( objtxtStampDutyAmt != null && document.getElementById('rowtxtStampDutyAmt').style.display != 'none' )
     {
        if(trim(objtxtStampDutyAmt.value) == '')
        { 
            alert("Please enter Stamp Duty Amount");
            objtxtStampDutyAmt.focus(); 
            return false;
        }
     }
}

ASPX:

  <tr id="rowTxtConsidAmt">
        <td class="formlabel">
            <asp:Label ID="lblConsidAmt" runat="server" Text="Consideration Amount" />
            &nbsp; (Rs.)&nbsp;<font class="textMandatory">*</font>
        </td>
   </tr>

Call is here:

<td colspan="6" class="formgrouptitle">
                            <asp:Button ID="btnPayment" runat="server" Text="Click here to make payment" CssClass="Button"
                                OnClick="btnPayment_Click" OnClientClick="return ValidateForm()" />
                        </td>

How to solve this?

According to the IE documentation getElementById is case-insensitive for versions less than 8. According to the Firefox documentation getElementById is case-sensitive. So you need to verify that your casing is the same between the HTML and what you pass to getElementById .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM