remove blank lines using javascript

<html>
 <head>
  <title>remove blank lines using javascript</title>
 </head>
 <body style="background:lightgray">
  <p>Click the button to test:</p>
  <button onclick="test()">remove blank lines</button>
  </br>
  <textarea id="edit" style="height:200px;width:240px">
line 1


line 2

line 3
  </textarea>
  <script>
  function test() {
   var edit= document.getElementById("edit");
   edit.value=removeBlankLines(edit.value);
  }
  function removeBlankLines(text) {
   return text.replace(/^\s*[\r\n]/gm,"");
  }
  </script>
 </body>
</html>

Comments

Popular posts from this blog

Format date as yyyy-mm-dd using vbscript

How to write data into a excel file using vbscript

android adb command usage