Feed on
Posts
Comments

To extend the String.prototype with the trim() function I use this line of code:

String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g,'’) }

This is sample code how to use the trim() function:

var sMyVar = new String (" testing trim ");
alert(sMyVar.trim());
 
//use it with the value of a text box
document.getElementById("txtMyTextBox").value.trim();

,
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati

Trackback URI | Comments RSS

Leave a Reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a