Remove blank lines from a textarea using Prototype

February 18, 2009 – 00:03

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

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

You can use it with “onblur” attribute:

<textarea id="some_text" onblur="removeBlankLines(this)"></textarea>
Share and Enjoy:
  • Digg
  • del.icio.us
  • Reddit
  • Facebook
  • BlinkList
  • Fark
  • Simpy
  • Slashdot
  • StumbleUpon
  • Technorati
  • LinkedIn
  • Mixx
  • MySpace
  • Google Bookmarks
  • Live
  • Yahoo! Buzz
  • DZone
  • Twitter
  • Yahoo! Bookmarks

Tags: , , , ,

Post a Comment