Handle on key up event for input text box - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Handle on key up event for input text box

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*  www  .  jav a  2  s.  c  o  m*/
document.getElementById('input-nickname').onkeyup = function(event) {
    this.value = this.value.replace(/[^a-z\d]/, '');
}
    }

      </script> 
   </head> 
   <body> 
      <input type="text" id="input-nickname">  
   </body>
</html>

Related Tutorials