Report if keycode and input are not empty - Javascript jQuery

Javascript examples for jQuery:Form Event

Description

Report if keycode and input are not empty

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-3.1.0.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/* ww w .j a  v a2  s.  c o m*/
$('#barcode').keypress(function(e) {
    if (e.which == 13 && this.value) {
        console.log("This works!");
    }
})
    }

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

Related Tutorials