Jquery replacing empty space in search form with # - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:val

Description

Jquery replacing empty space in search form with #

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.1.js"></script> 
  <script type="text/javascript">
    window.onload=function(){//from w w w . j ava2s.co m
 $("#s").keyup(function () {
        var textValue = $(this).val();
        textValue = textValue.replace(/ /g,"#");
        $(this).val(textValue);
    });
    }

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

Related Tutorials