1

Here i have passed the text control to the java script function but i just want to pass the value of the text box to the java script function instead on onkeyup.

function Changed(textControl) {
    var _txtEmpName = document.getElementById('<%=txtEmpName.ClientID%>');

    var _EnteredString = _txtEmpName.value;

<asp:TextBox
        ID="txtEmpName" runat="server" onkeyup="javascript: Changed( this );"></asp:TextBox>
2
  • document.getElementById('<%=txtEmpName.ClientID%>').value ? Commented Aug 24, 2012 at 15:30
  • See this url it's working nice for me... [How to call javascript function on keyup event for asp:TextBox][1] [1]: stackoverflow.com/questions/5607313/… Commented Jul 14, 2013 at 18:06

3 Answers 3

3

If you want to pass the value instead, simply do:

<asp:TextBox ID="txtEmpName" runat="server" 
 onkeyup="javascript: Changed( this.value );"></asp:TextBox>
Sign up to request clarification or add additional context in comments.

Comments

2

Not sure if I understand, but if you want to pass the value you should use this.value instead of just this

<asp:TextBox ID="txtEmpName" runat="server" onkeyup="Changed(this.value)">
</asp:TextBox>

Comments

0

Maybe use onblur instead of onkeyup? You will be calling that function with every keystroke, is that something you really want to do?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.