By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,730 Members | 1,546 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,730 IT Pros & Developers. It's quick & easy.

trim function

P: 31
Hi,
I am newbie to the javascript
I need to validate the text box,
i want to enter the blank value in the text box,
so in order to remove white spaces, i had used trim function,
but it is not effected and it gives me javascript error in IE6,

Even the example of w3school is also not working in IE6.

Please help me out....!!!!

Thanks in advance
Feb 5 '10 #1
Share this Question
Share on Google+
2 Replies


P: 9
Expand|Select|Wrap|Line Numbers
  1. function trimStr(value)
  2. {
  3.     return value.replace(/^\s+|\s+$/g, '')
  4. }
Feb 5 '10 #2

Dormilich
Expert Mod 5K+
P: 8,639
use native methods, if available.
Expand|Select|Wrap|Line Numbers
  1. function trimStr(value)
  2. {
  3.     if (value.trim) {
  4.         return value.trim();
  5.     }
  6.     return value.replace(/^\s+|\s+$/g, '');
  7. }
Feb 5 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.