Check input field value in keydown event handler - Javascript jQuery

Javascript examples for jQuery:Form Event

Description

Check input field value in keydown event handler

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> 
      <script type="text/javascript">
    $(function(){//  w  w  w  .  ja  va2  s.  c  om
$('.text').on('keydown', function(e) {
    if ($(this).val().length >= 3) {
        console.log('d');
    }
});
    });

      </script> 
   </head> 
   <body> 
      <textarea class="text"></textarea>  
   </body>
</html>

Related Tutorials