Eliminate white space from input field - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Eliminate white space from input field

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(){/*ww  w.  j a  v  a 2s.  c om*/
document.getElementById('mail').addEventListener('keydown' ,function(e) {
    var k =e.keyCode
    k ==32 &&e.preventDefault()
})
    }

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

Related Tutorials