henrysu
07-10-2002, 12:18 AM
Hi,
Is there a trim() function in Javascript? I am trying to find one, can anybody give me a hand?
Henry
Is there a trim() function in Javascript? I am trying to find one, can anybody give me a hand?
Henry
|
||||
how to trim a stringhenrysu 07-10-2002, 12:18 AM Hi, Is there a trim() function in Javascript? I am trying to find one, can anybody give me a hand? Henry jkd 07-10-2002, 12:32 AM String.prototype.trim = function() { return this.replace(/^\s+/,'').replace(/\s+$/,''); } Now: ' hello '.trim() == 'hello' :) rama 07-10-2002, 04:00 AM Hi, How to call the function with a event handler in an textbox Thanks Rama jkd 07-10-2002, 04:01 AM Umm, assuming that code was declared elsewhere in the page: onblur="this.value = this.value.trim()" |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum