<!DOCTYPE html> <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=windows-1251' /> <!-- <script src='http://code.jquery.com/jquery-latest.js'></script> <script src="https://code.angularjs.org/1.3.9/angular.min.js"></script> <script src="https://code.angularjs.org/1.3.9/angular-route.js"></script> --> <style type='text/css'> </style> <script type='text/javascript'> function test(){ alert(document.getElementById('txt').value.replace(/\n+/g,'\n')); }; </script> </head> <body> <textarea id='txt'></textarea> <button onclick='test();'>Go</button> </body> </html>