Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / Javascript

Recent value with KeyPress

0.00/5 (No votes)
6 Sep 2011CPOL 5.6K  
You can pass object as parameter to generalize function function showContent(e,object) { var recentChar...
You can pass object as parameter to generalize function

XML
<asp:TextBox ID="txtName"  onkeypress="showContent(event,this)" ClientIDMode="Static" runat="server">
<label id="lblPrview" ></label>
 
<script type="text/javascript">
      function showContent(e,object) {
          var recentChar = String.fromCharCode(e.which);
          var completetext = object.value + recentChar;
 
           // assign value using js
          document.getElementById('lblPrview').innerHTML = completetext;
      }
  </script>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)