How to make asp textbox keystroke event?

Hi everyone, I am writing varus asp text field controls calculations. I want my calculations to be done with a keystroke. Below is the code I'm using but not working

.aspx page

<asp:TextBox ID="txtMaintCost onkeypress="calculateFinanceDetail(); return false;" runat="server"></asp:TextBox>

.js file

function calculateFinanceDetail() {
            var txtMaintCost = $('input[id$=txtMaintCost]').val();
            var txtInstallCost = $('input[id$=txtInstallCost]').val();
            var txtFreightCost = $('input[id$=txtFreightCost]').val();
}

its not a calling javascript function on a keystroke event ... If anyone has any ideas than please help me with this.

+5
source share
2 answers

Missing "at the end of the text field identifier.

Change

<asp:TextBox ID="txtMaintCost onkeypress="calculateFinanceDetail(); return false;" runat="server"></asp:TextBox>

To

<asp:TextBox ID="txtMaintCost" onkeypress="calculateFinanceDetail(); return false;" runat="server"></asp:TextBox>

ClientID . , static ids . wild cards, .

function calculateFinanceDetail() {
      var txtMaintCost = $('input[id=<%=txtMaintCost.ClientID%>]').val();
      var txtInstallCost = $('input[id=<%=txtInstallCost.ClientID%>]').val();
      var txtFreightCost = $('input[id=<%=txtFreightCost.ClientID%>]').val();
}
+6

ID="txtMaintCost onkeypress=", ID="txtMaintCost" "onkeypress="

+5

All Articles