<html>
<script type="text/javascript">
   function Textor(txtid)
   {
     this.text=txtid;
     this.init();
   }
   Textor.prototype.init=function()
   {
     this.text.onkeyup = function(oEvent)
 {
        alert('按键起来');
     }
   
   }
</script>
        <script type="text/javascript">
            window.onload = function () {
              var txtor =  new Textor(document.getElementById('username'));
            }
        </script>
<body>
  <input type="text" name="username" id="username"/>
</body>
</html>