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>

Published by Cristian Radulescu

PHP // MySql // Linux

Leave a comment

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.