Click here to Skip to main content
15,886,059 members
Articles / Programming Languages / Javascript
Alternative
Tip/Trick

Recent value with KeyPress

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
6 Sep 2011CPOL 5.4K  
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)


Written By
Software Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --