Sunday 28 July 2013

Jquery - Get the TextBox value on Change event and Store in another TextBox

Now we see how to get the value of  TextBox on change event using JQuery.

Now we the Html code In the below code, Two TextBox are created.

<html>
<head>
     <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <meta charset=utf-8 />
        <title>JS Bin</title>
 </head>
<body>
   <input type="text" id="txt1" />
   <input type="text" id="txt2"/> 
</body>
</html>

Now Let we see the JQuery Code to access the Textbox, Jquery code is written for the textbox object with id of txt1, On change Event.

$('#txt1').change(function()
{

  var result = document.getElementById('txt1').value;
  document.getElementById('txt2').value = result;

});



Click Here to See Full Source code
Click Here to see the Output