65.9K
CodeProject is changing. Read more.
Home

Recent value with KeyPress

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Sep 6, 2011

CPOL
viewsIcon

5627

You can pass object as parameter to generalize function function showContent(e,object) { var recentChar...

You can pass object as parameter to generalize function
<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>