Removing spaces from text filed value using regex and string replace method - Javascript RegExp

Javascript examples for RegExp:Match Space

Description

Removing spaces from text filed value using regex and string replace method

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(){//  w w  w  .  j  a  v  a  2  s  .co  m
var input = document.getElementById('lmt_c13');
input.addEventListener('blur', function () {
    this.value = this.value.replace(/\s+/g, '');
}, false);
    }

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

Related Tutorials