Login or Sign Up
Logging in...
Remember me
Log in
Forgot password or user name?
or
Sign Up
Log in with
Search in titles only
Search in JavaScript programming only
Search
Advanced Search
Forum
Groups
Today’s Posts
Calendar
Forum
Client side development
JavaScript programming
Announcement
Collapse
No announcement yet.
how to trim a string
Collapse
X
Collapse
Posts
Latest Activity
Photos
Search
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
henrysu
New to the CF scene
Join Date:
Jul 2002
Posts:
2
Share
Tweet
#1
how to trim a string
Jul 9, 2002, 07:18 PM
Hi,
Is there a trim() function in Javascript? I am trying to find one, can anybody give me a hand?
Henry
jkd
New to the CF scene
Join Date:
May 2002
Posts:
3507
Share
Tweet
#2
Jul 9, 2002, 07:32 PM
String.prototype.trim = function() {
return this.replace(/^\s+/,'').replace(/\s+$/,'');
}
Now:
' hello '.trim() == 'hello'
jasonkarldavis.com
Comment
Post
Cancel
rama
New to the CF scene
Join Date:
Jun 2002
Posts:
18
Share
Tweet
#3
Jul 9, 2002, 11:00 PM
trim a string
Hi,
How to call the function with a event handler in an textbox
Thanks
Rama
Comment
Post
Cancel
jkd
New to the CF scene
Join Date:
May 2002
Posts:
3507
Share
Tweet
#4
Jul 9, 2002, 11:01 PM
Umm, assuming that code was declared elsewhere in the page:
onblur="this.value = this.value.trim()"
jasonkarldavis.com
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
X
Comment