js being prompted to input the input box spaces directly verify the removal of spaces

   <input type="text" id="test"/>
    <input type="button" value="test" id="btn_test" onclick="tt()" />
     <script>
         function tt() {
             var t = document.getElementById("test").value
             var patt1 = new RegExp(/\s+/g);
             if (patt1.test(t)) {
                 alert("Spaces " ); 
             } 
             Alert (t.replace ( / \ + S / G, " " )); 
         } 
</ Script >

 

Guess you like

Origin www.cnblogs.com/li-sir/p/10983645.html