Comments
News - HTML Textarea: Selection and caret position
Protected EmailaddressWebsite
Posted on 30-01-2009 12:49
Your comment:
Trims all newlines on the back of the string (not real friendly code, though)
function StripLastNewLines(s){
while ((s.substring(s.length - 1, s.length) == "\n") || (s.substring(s.length - 1, s.length) == "\r"))
s = s.substring(0, s.length - 1);
return s;
}


This is that Regular Expressions are made for

function StripLastNewLines(s){
return s.replace(/[\n\r]*$/,'');
}


/ [\n\r] * $ /

[\n\r] class will match \n or \r
* will find 0 or more
$ at the end of the string

And thanks for the functions

Alf
Name *:
Email *:
Website:
Verification *:
Comment *:
Make selected text bold
Make selected text italic
Underscore selected text
Convert selected text as ordered list
Convert selected text as unordered list
Add an internal link
Add an external image
Add an email address
Add a link
Add an emoticon
Add an external image, using Google Images
Add a YouTube movie
Preview
Help
This field is required
This is not a valid number
This is not a valid e-mail address
This number should have a value between %min% an %max%
This %name% already exists
This is not a valid date
This is not a valid time