Remove blank lines from a textarea using Prototype

Here is a JavaScript function used to remove blank lines from a textarea. This snippet is using the Prototype JavaScript framework

function removeBlankLines(field)
{
  $(field).value=$(field).value.gsub(/\s+/, '\r\n');
}

You can use it with “onblur” attribute:

<textarea id="some_text"></textarea>

About Cristian Radulescu

PHP // MySql // Linux // Android
This entry was posted in HTML, JavaScript, Programming and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>