Text change events in jquery with Asp.net

coder picture coder · Nov 1, 2011 · Viewed 13.4k times · Source

I have 2 textboxes and If I write anythng in textbox1 it should reflect immediately in textbox2 and If I write anything in textbox2 it should reflect in textbox1.

So how do I do that? I have seen this article before and how to Implement between two textboxes?

http://www.zurb.com/playground/jquery-text-change-custom-event

Here are my textboxes:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>

Answer

Sedat Başar picture Sedat Başar · Nov 1, 2011
$('#TextBox1').keydown(function(){
    $('#TextBox2').val($(this).val())
})
$('#TextBox2').keydown(function(){
    $('#TextBox1').val($(this).val())
})